KnpGaufretteBundle/DependencyInjection/Factory/MogileFSAdapterFactory.php

53 lines
1.3 KiB
PHP
Raw Permalink Normal View History

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')
2011-10-17 13:46:47 +00:00
->requiresAtLeastOneElement()
->prototype('scalar')->end()
2011-10-11 11:40:51 +00:00
->end()
->end()
;
}
}