Add support for Google Cloud Storage

This commit is contained in:
Patrik Karisch 2014-11-01 11:28:57 +01:00
parent c88039e80c
commit db25e67b10
3 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,55 @@
<?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 GoogleCloudStorageAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.google_cloud_storage'))
->addArgument(new Reference($config['service_id']))
->addArgument($config['bucket_name'])
->addArgument($config['options'])
->addArgument($config['detect_content_type'])
;
}
/**
* {@inheritDoc}
*/
public function getKey()
{
return 'google_cloud_storage';
}
/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $builder)
{
$builder
->children()
->scalarNode('service_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()
->booleanNode('detect_content_type')->defaultTrue()->end()
->arrayNode('options')
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue('')->end()
->scalarNode('acl')->defaultValue('private')->end()
->end()
->end()
->end()
;
}
}

View File

@ -35,6 +35,9 @@
<service id="knp_gaufrette.adapter.factory.azure_blob_storage" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AzureBlobStorageAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.google_cloud_storage" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\GoogleCloudStorageAdapterFactory">
<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>

View File

@ -33,6 +33,7 @@
<argument /><!-- Detect content type -->
</service>
<service id="knp_gaufrette.adapter.azure_blob_storage" class="Gaufrette\Adapter\AzureBlobStorage" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.google_cloud_storage" class="Gaufrette\Adapter\GoogleCloudStorage" abstract="true" public="false" />
<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 -->