adds AmazonS3 adapter factory
This commit is contained in:
parent
6ca918cc26
commit
00a3fab9bc
54
DependencyInjection/Factory/AmazonS3AdapterFactory.php
Normal file
54
DependencyInjection/Factory/AmazonS3AdapterFactory.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?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
|
||||
{
|
||||
/**
|
||||
* Creates the adapter, registers it and returns its id
|
||||
*
|
||||
* @param ContainerBuilder $container A ContainerBuilder instance
|
||||
* @param string $id The id of the service
|
||||
* @param array $config An array of configuration
|
||||
*/
|
||||
public function create(ContainerBuilder $container, $id, array $config)
|
||||
{
|
||||
$container
|
||||
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.amazon_s3'))
|
||||
->addArgument(new Reference($config['amazon_s3_id']))
|
||||
->addArgument($config['bucket_name'])
|
||||
->addArgument($config['create'])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the factory configuration
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return 'amazon_s3';
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds configuration nodes for the factory
|
||||
*
|
||||
* @param NodeBuilder $builder
|
||||
*/
|
||||
public function addConfiguration(NodeDefinition $builder)
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
->scalarNode('amazon_s3_id')->isRequired()->cannotBeEmpty()->end()
|
||||
->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()
|
||||
->booleanNode('create')->defaultFalse()->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
|
@ -17,6 +17,9 @@
|
|||
<service id="knp_gaufrette.adapter.factory.safe_local" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\SafeLocalAdapterFactory">
|
||||
<tag name="gaufrette.adapter.factory" />
|
||||
</service>
|
||||
<service id="knp_gaufrette.adapter.factory.amazon_s3" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AmazonS3AdapterFactory">
|
||||
<tag name="gaufrette.adapter.factory" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<argument /><!-- Directory -->
|
||||
<argument /><!-- Create -->
|
||||
</service>
|
||||
<service id="knp_gaufrette.adapter.amazon_s3" class="Gaufrette\Adapter\AmazonS3" abstract="true" public="false" />
|
||||
<service id="knp_gaufrette.filesystem_map" class="Knp\Bundle\GaufretteBundle\FilesystemMap">
|
||||
<argument /> <!-- map of filesystems -->
|
||||
</service>
|
||||
|
|
Loading…
Reference in New Issue
Block a user