8 Commits
0.2.0 ... 0.3.0

Author SHA1 Message Date
Andrew Kovalyov
44cf552e14 Add travis badge 2016-01-16 02:12:11 +02:00
Andrew Kovalyov
59afa91134 Rename README.markdown to README.md 2016-01-16 02:11:43 +02:00
Andrew Kovalyov
988188477f Prepare for 0.3 2016-01-16 02:08:29 +02:00
Albin Kerouanton
45dc19248b Merge pull request #127 from tgabi333/sf3
[WIP] allow symfony3
2015-12-07 11:14:48 +01:00
Tóth Gábor
ad36fa50d0 allow sf3 2015-12-03 19:29:31 +01:00
Florian Klein
0b2750033a Merge pull request #102 from Karisch/feature/google-cloud-storage
Add support for Google Cloud Storage
2015-11-10 10:25:29 +01:00
Patrik Karisch
65f587ae17 Add documentation 2014-11-01 12:28:12 +01:00
Patrik Karisch
db25e67b10 Add support for Google Cloud Storage 2014-11-01 12:27:35 +01:00
6 changed files with 135 additions and 8 deletions

View File

@@ -1,12 +1,33 @@
language: php
sudo: false
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
before_script:
- curl -s http://getcomposer.org/installer | php -- --quiet
- php composer.phar install --dev
cache:
directories:
- $HOME/.composer/cache
matrix:
include:
- php: 5.6
env: SYMFONY_VERSION='~2.3'
- php: 5.6
env: SYMFONY_VERSION='~2.8'
- php: 5.6
env: SYMFONY_VERSION='~3.0'
before_install:
- composer self-update
- sh -c 'if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony=$SYMFONY_VERSION; fi;'
install: composer install
script:
- php bin/phpunit --coverage-text

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

@@ -1,6 +1,8 @@
Gaufrette Bundle
================
[![Build Status](https://travis-ci.org/KnpLabs/KnpGaufretteBundle.svg?branch=master)](https://travis-ci.org/KnpLabs/KnpGaufretteBundle)
Provides a [Gaufrette][gaufrette-homepage] integration for your Symfony projects.
About Gaufrette
@@ -643,6 +645,51 @@ knp_gaufrette:
container_name: foo
```
## GoogleCloudStorage
Adapter for Google APIs Client Library for PHP.
### Parameters
* `service_id` The service id of the `\Google_Service_Storage` to use. *(required)*
* `bucket_name` The name of the GCS bucket to use. *(required)*
* `detect_content_type`: if `true` will detect the content type for each file *(default `true`)*
* `options` A list of additional options passed to the adapter.
* `directory` A directory to operate in. *(default '')*
* `acl` Whether the uploaded files should be `private` or `public` *(default `private`)*
### Defining services
You need to create a custom factory service which creates a `\Google_Client` and authorizes with the correct scopes
and then returns a `\Google_Service_Storage` class connected to the client class:
```yaml
services:
app.google_cloud_storage.service:
class: \Google_Service_Storage
factory_class: App\Factory\GoogleCloudStorageServiceFactory
factory_method: 'createService'
arguments:
-
# all the arguments needed like service account email and path to key.p12
```
### Example
Once the service is set up use its key as the `service_id` in the gaufrette configuration:
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
profile_photos:
google_cloud_storage:
service_id: 'app.google_cloud_storage.service'
bucket_name: 'images'
options:
directory: 'profile_photos'
```
## Cache (cache)
Adapter which allows you to cache other adapters

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 -->

View File

@@ -16,12 +16,12 @@
}
],
"require": {
"symfony/framework-bundle": "2.*",
"knplabs/gaufrette": "~0.1.7|0.2.*@dev"
"symfony/framework-bundle": "~2.0|~3.0",
"knplabs/gaufrette": "~0.1.7|~0.2"
},
"require-dev": {
"symfony/yaml": "2.*",
"symfony/console": "2.*",
"symfony/yaml": "~2.0|~3.0",
"symfony/console": "~2.0|~3.0",
"phpunit/phpunit": "~4.2"
},
"autoload": {
@@ -31,7 +31,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.2.x-dev"
"dev-master": "0.4.x-dev"
}
},
"config": {