2011-05-08 21:04:37 +00:00
|
|
|
<?php
|
|
|
|
|
2011-07-03 09:38:38 +00:00
|
|
|
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
|
2011-05-08 21:04:37 +00:00
|
|
|
|
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
|
|
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Safe local adapter factory
|
|
|
|
*
|
|
|
|
* @author Antoine Hérault <antoine.herault@gmail.com>
|
|
|
|
*/
|
|
|
|
class SafeLocalAdapterFactory implements AdapterFactoryInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function create(ContainerBuilder $container, $id, array $config)
|
|
|
|
{
|
|
|
|
$container
|
2011-07-03 09:38:38 +00:00
|
|
|
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.safe_local'))
|
2011-05-08 21:04:37 +00:00
|
|
|
->replaceArgument(0, $config['directory'])
|
|
|
|
->replaceArgument(1, $config['create'])
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function getKey()
|
|
|
|
{
|
|
|
|
return 'safe-local';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function addConfiguration(NodeDefinition $node)
|
|
|
|
{
|
|
|
|
$node
|
|
|
|
->children()
|
|
|
|
->scalarNode('directory')->isRequired()->end()
|
|
|
|
->booleanNode('create')->defaultTrue()->end()
|
|
|
|
->end()
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|