Added OpenCloudAdapterFactory

This commit is contained in:
Luciano Mammino 2013-04-11 22:51:52 +02:00
parent 013f50495b
commit 2a3cae7156
3 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,53 @@
<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
/**
* OpenCloud adapter factory
*
* @author Mammino Luciano 2013 <lmammino@oryzone.com>
*/
class OpenCloudAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.opencloud'))
->replaceArgument(0, new Reference($config['object_store_id']))
->replaceArgument(1, $config['container_name'])
->replaceArgument(2, $config['create_container'])
->replaceArgument(3, $config['detect_content_type'])
;
}
/**
* {@inheritDoc}
*/
public function getKey()
{
return 'opencloud';
}
/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('object_store_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('container_name')->isRequired()->cannotBeEmpty()->end()
->booleanNode('create_container')->defaultFalse()->end()
->booleanNode('detect_content_type')->defaultTrue()->end()
->end()
;
}
}

View File

@ -23,6 +23,9 @@
<service id="knp_gaufrette.adapter.factory.acl_aware_amazon_s3" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AclAwareAmazonS3AdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.opencloud" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\OpenCloudAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.gridfs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\GridFSAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
@ -45,3 +48,4 @@
</services>
</container>

View File

@ -24,6 +24,12 @@
</service>
<service id="knp_gaufrette.adapter.amazon_s3" class="Gaufrette\Adapter\AmazonS3" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.acl_aware_amazon_s3" class="Gaufrette\Adapter\AclAwareAmazonS3" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.opencloud" class="Gaufrette\Adapter\OpenCloud" abstract="true" public="false">
<argument /><!-- ObjectStore -->
<argument /><!-- Container name -->
<argument /><!-- Create container -->
<argument /><!-- Detect content type -->
</service>
<service id="knp_gaufrette.adapter.gridfs" class="Gaufrette\Adapter\GridFS" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.mogilefs" class="Gaufrette\Adapter\MogileFS" abstract="true" public="false">
<argument /><!-- domain -->
@ -42,3 +48,4 @@
</services>
</container>