KnpGaufretteBundle/DependencyInjection/Factory/AwsS3AdapterFactory.php
2013-09-26 19:50:50 +02:00

56 lines
1.6 KiB
PHP

<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
class AwsS3AdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.aws_s3'))
->addArgument(new Reference($config['service_id']))
->addArgument($config['bucket_name'])
->addArgument($config['options'])
;
}
/**
* {@inheritDoc}
*/
public function getKey()
{
return 'aws_s3';
}
/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $builder)
{
$builder
->children()
->scalarNode('service_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()
->arrayNode('options')
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue('')->end()
->booleanNode('create')
->defaultFalse()
->end()
->end()
->end()
->end()
;
}
}