2011-10-11 11:40:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
|
|
|
|
|
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
|
|
|
use Symfony\Component\DependencyInjection\Reference;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
|
|
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GridFS adapter factory
|
|
|
|
*
|
2011-10-12 07:09:43 +00:00
|
|
|
* @author Mikko Tarvainen 2011 <mtarvainen@gmail.com>
|
2011-10-11 11:40:51 +00:00
|
|
|
*/
|
|
|
|
class MogileFSAdapterFactory implements AdapterFactoryInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function create(ContainerBuilder $container, $id, array $config)
|
|
|
|
{
|
|
|
|
$container
|
|
|
|
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.mogilefs'))
|
|
|
|
->replaceArgument(0, $config['domain'])
|
|
|
|
->replaceArgument(1, $config['hosts'])
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function getKey()
|
|
|
|
{
|
|
|
|
return 'mogilefs';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function addConfiguration(NodeDefinition $node)
|
|
|
|
{
|
|
|
|
$node
|
|
|
|
->children()
|
|
|
|
->scalarNode('domain')->isRequired()->cannotBeEmpty()->end()
|
|
|
|
->arrayNode('hosts')
|
|
|
|
->prototype('scalar')->isRequired()->end()
|
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|