52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
|
<?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
|
||
|
*
|
||
|
* @author Mikko Tarvainen
|
||
|
*/
|
||
|
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()
|
||
|
;
|
||
|
}
|
||
|
}
|