2013-08-21 14:20:35 +00:00
|
|
|
<?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()
|
2013-11-12 18:14:41 +00:00
|
|
|
->booleanNode('create')->defaultFalse()->end()
|
|
|
|
->scalarNode('acl')->defaultValue('private')->end()
|
2013-08-21 14:20:35 +00:00
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|