2011-09-27 08:50:39 +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\DefinitionDecorator;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
|
|
|
|
|
|
class AmazonS3AdapterFactory implements AdapterFactoryInterface
|
|
|
|
{
|
|
|
|
/**
|
2013-01-21 10:07:19 +00:00
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2011-09-27 08:50:39 +00:00
|
|
|
public function create(ContainerBuilder $container, $id, array $config)
|
|
|
|
{
|
2012-11-14 14:36:59 +00:00
|
|
|
$definition = $container
|
2011-09-27 08:50:39 +00:00
|
|
|
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.amazon_s3'))
|
|
|
|
->addArgument(new Reference($config['amazon_s3_id']))
|
2012-11-14 14:36:59 +00:00
|
|
|
->addArgument($config['bucket_name']);
|
|
|
|
|
|
|
|
if (isset($config['options'])) {
|
|
|
|
$definition->addArgument($config['options']);
|
2012-11-16 08:30:13 +00:00
|
|
|
} elseif (isset($config['create'])) {
|
|
|
|
$definition->addArgument(array('create' => $config['create']));
|
2012-11-14 14:36:59 +00:00
|
|
|
}
|
2011-09-27 08:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-21 10:07:19 +00:00
|
|
|
* {@inheritDoc}
|
2011-09-27 08:50:39 +00:00
|
|
|
*/
|
|
|
|
public function getKey()
|
|
|
|
{
|
|
|
|
return 'amazon_s3';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-21 10:07:19 +00:00
|
|
|
* {@inheritDoc}
|
2011-09-27 08:50:39 +00:00
|
|
|
*/
|
|
|
|
public function addConfiguration(NodeDefinition $builder)
|
|
|
|
{
|
|
|
|
$builder
|
|
|
|
->children()
|
|
|
|
->scalarNode('amazon_s3_id')->isRequired()->cannotBeEmpty()->end()
|
|
|
|
->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()
|
2012-11-16 08:30:13 +00:00
|
|
|
->booleanNode('create')->end()
|
2012-11-14 14:36:59 +00:00
|
|
|
->arrayNode('options')
|
|
|
|
->children()
|
|
|
|
->booleanNode('create')
|
|
|
|
->defaultFalse()
|
|
|
|
->end()
|
|
|
|
->scalarNode('region')->end()
|
|
|
|
->scalarNode('directory')->end()
|
|
|
|
->end()
|
|
|
|
->end()
|
2011-09-27 08:50:39 +00:00
|
|
|
->end()
|
|
|
|
;
|
|
|
|
}
|
2012-11-14 14:36:59 +00:00
|
|
|
}
|