KnpGaufretteBundle/DependencyInjection/Factory/AwsS3AdapterFactory.php

57 lines
1.7 KiB
PHP
Raw Normal View History

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'])
->addArgument($config['detect_content_type'])
2013-08-21 14:20:35 +00:00
;
}
/**
* {@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()
->booleanNode('detect_content_type')->defaultFalse()->end()
2013-08-21 14:20:35 +00:00
->arrayNode('options')
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue('')->end()
->booleanNode('create')->defaultFalse()->end()
->scalarNode('acl')->defaultValue('private')->end()
2013-08-21 14:20:35 +00:00
->end()
->end()
->end()
;
}
}