Merge pull request #67 from radutopala/master
Dropbox Adapter Factory added
This commit is contained in:
commit
9e70925730
45
DependencyInjection/Factory/DropboxAdapterFactory.php
Normal file
45
DependencyInjection/Factory/DropboxAdapterFactory.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* Dropbox Adapter Factory
|
||||
*/
|
||||
class DropboxAdapterFactory implements AdapterFactoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function create(ContainerBuilder $container, $id, array $config)
|
||||
{
|
||||
$container
|
||||
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.dropbox'))
|
||||
->addArgument(new Reference($config['api_id']))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function getKey()
|
||||
{
|
||||
return 'dropbox';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function addConfiguration(NodeDefinition $builder)
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
->scalarNode('api_id')->cannotBeEmpty()->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
|
@ -809,4 +809,46 @@ knp_gaufrette:
|
|||
checksum: checksum
|
||||
```
|
||||
|
||||
## Dropbox (dropbox)
|
||||
|
||||
Adapter for Dropbox.
|
||||
|
||||
### Parameters
|
||||
|
||||
* `api_id` The id of the service that provides Dropbox API access.
|
||||
|
||||
### Example
|
||||
|
||||
> In order to get a Dropbox token and token_secret, you need to add a new Dropbox App in your account, and then you'll need to go through the oAuth authorization process
|
||||
|
||||
``` yaml
|
||||
# app/config/config.yml
|
||||
knp_gaufrette:
|
||||
adapters:
|
||||
foo:
|
||||
dropbox:
|
||||
api_id: acme_test.dropbox.api
|
||||
```
|
||||
|
||||
In your AcmeTestBundle, add following service definitions:
|
||||
|
||||
``` yaml
|
||||
# src/Acme/TestBundle/Resources/config/services.yml
|
||||
parameters:
|
||||
acme_test.dropbox.key: my_consumer_key
|
||||
acme_test.dropbox.secret: my_consumer_secret
|
||||
acme_test.dropbox.token: some_token
|
||||
acme_test.dropbox.token_secret: some_token_secret
|
||||
|
||||
services:
|
||||
acme_test.dropbox.oauth:
|
||||
class: Dropbox_OAuth_Curl
|
||||
arguments: [%acme_test.dropbox.key%, %acme_test.dropbox.secret%]
|
||||
calls:
|
||||
- [setToken, ["%acme_test.dropbox.token%", "%acme_test.dropbox.token_secret%"]]
|
||||
acme_test.dropbox.api:
|
||||
class: Dropbox_API
|
||||
arguments: [@acme_test.dropbox.oauth, "sandbox"]
|
||||
```
|
||||
|
||||
[gaufrette-homepage]: https://github.com/KnpLabs/Gaufrette
|
||||
|
|
|
@ -53,7 +53,9 @@
|
|||
<service id="knp_gaufrette.adapter.factory.cache" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\CacheAdapterFactory">
|
||||
<tag name="gaufrette.adapter.factory" />
|
||||
</service>
|
||||
|
||||
<service id="knp_gaufrette.adapter.factory.dropbox" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\DropboxAdapterFactory">
|
||||
<tag name="gaufrette.adapter.factory" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
<service id="knp_gaufrette.filesystem_map" class="%knp_gaufrette.filesystem_map.class%">
|
||||
<argument /> <!-- map of filesystems -->
|
||||
</service>
|
||||
<service id="knp_gaufrette.adapter.dropbox" class="Gaufrette\Adapter\Dropbox" abstract="true" public="false" />
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
Loading…
Reference in New Issue
Block a user