commit
81526bc7ca
47
DependencyInjection/Factory/GridFSAdapterFactory.php
Normal file
47
DependencyInjection/Factory/GridFSAdapterFactory.php
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GridFS adapter factory
|
||||||
|
*
|
||||||
|
* @author Tomi Saarinen <tomi.saarinen@rohea.com>
|
||||||
|
*/
|
||||||
|
class GridFSAdapterFactory implements AdapterFactoryInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function create(ContainerBuilder $container, $id, array $config)
|
||||||
|
{
|
||||||
|
$container
|
||||||
|
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.gridfs'))
|
||||||
|
->addArgument(new Reference($config['mongogridfs_id']))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getKey()
|
||||||
|
{
|
||||||
|
return 'gridfs';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function addConfiguration(NodeDefinition $node)
|
||||||
|
{
|
||||||
|
$node
|
||||||
|
->children()
|
||||||
|
->scalarNode('mongogridfs_id')->isRequired()->cannotBeEmpty()->end()
|
||||||
|
->end()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
|
@ -141,7 +141,7 @@ A simple local filesystem based adapter.
|
||||||
* `directory` The directory of the filesystem *(required)*
|
* `directory` The directory of the filesystem *(required)*
|
||||||
* `create` Whether to create the directory if it does not exist *(default true)*
|
* `create` Whether to create the directory if it does not exist *(default true)*
|
||||||
|
|
||||||
### Exemple
|
### Example
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
# app/config/config.yml
|
# app/config/config.yml
|
||||||
|
@ -162,7 +162,7 @@ Almost as simple as the **local** adapter, but it encodes key to avoid having to
|
||||||
* `directory` The directory of the filesystem *(required)*
|
* `directory` The directory of the filesystem *(required)*
|
||||||
* `create` Whether to create the directory if it does not exist *(default true)*
|
* `create` Whether to create the directory if it does not exist *(default true)*
|
||||||
|
|
||||||
### Exemple
|
### Example
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
# app/config/config.yml
|
# app/config/config.yml
|
||||||
|
@ -182,7 +182,7 @@ Allows you to use a user defined adapter service.
|
||||||
|
|
||||||
* `id` The id of the service *(required)*
|
* `id` The id of the service *(required)*
|
||||||
|
|
||||||
### Exemple
|
### Example
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
# app/config/config.yml
|
# app/config/config.yml
|
||||||
|
@ -203,7 +203,7 @@ Adapter for test purposes, it stores files in an internal array.
|
||||||
|
|
||||||
The `files` is an array of files where each file is a sub-array having the `content`, `checksum` and `mtime` optional keys.
|
The `files` is an array of files where each file is a sub-array having the `content`, `checksum` and `mtime` optional keys.
|
||||||
|
|
||||||
### Exemple
|
### Example
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
# app/config/config.yml
|
# app/config/config.yml
|
||||||
|
@ -219,4 +219,46 @@ knp_gaufrette:
|
||||||
mtime: 123456890123
|
mtime: 123456890123
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## GridFS (gridfs)
|
||||||
|
|
||||||
|
Allows you to use a gridfs as an adapter.
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
* `mongogridfs_id` The id of the service that provides MongoGridFS object instance for adapter *(required)*
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
# app/config/config.yml
|
||||||
|
knp_gaufrette:
|
||||||
|
adapters:
|
||||||
|
foo:
|
||||||
|
gridfs:
|
||||||
|
mongogridfs_id: acme_test.gridfs
|
||||||
|
```
|
||||||
|
|
||||||
|
In your AcmeTestBundle, add following service definitions:
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
# src/Acme/TestBundle/Resources/config/services.yml
|
||||||
|
parameters:
|
||||||
|
acme_test.mongo.server: "mongodb://localhost:27017"
|
||||||
|
acme_test.mongo.options:
|
||||||
|
connect: true
|
||||||
|
acme_test.mongodb.name: "test_database"
|
||||||
|
acme_test.gridfs.prefix: "fs" #Default
|
||||||
|
services:
|
||||||
|
acme_test.mongo:
|
||||||
|
class: Mongo
|
||||||
|
arguments: [%acme_test.mongo.server%, %acme_test.mongo.options%]
|
||||||
|
acme_test.mongodb:
|
||||||
|
class: MongoDB
|
||||||
|
arguments: [@acme_test.mongo, %acme_test.mongodb.name%]
|
||||||
|
acme_test.gridfs:
|
||||||
|
class: MongoGridFS
|
||||||
|
arguments: [@acme_test.mongodb, %acme_test.gridfs.prefix%]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
[gaufrette-homepage]: https://github.com/knplabs/Gaufrette
|
[gaufrette-homepage]: https://github.com/knplabs/Gaufrette
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
<service id="knp_gaufrette.adapter.factory.acl_aware_amazon_s3" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AclAwareAmazonS3AdapterFactory">
|
<service id="knp_gaufrette.adapter.factory.acl_aware_amazon_s3" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AclAwareAmazonS3AdapterFactory">
|
||||||
<tag name="gaufrette.adapter.factory" />
|
<tag name="gaufrette.adapter.factory" />
|
||||||
</service>
|
</service>
|
||||||
|
<service id="knp_gaufrette.adapter.factory.gridfs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\GridFSAdapterFactory">
|
||||||
|
<tag name="gaufrette.adapter.factory" />
|
||||||
|
</service>
|
||||||
</services>
|
</services>
|
||||||
|
|
||||||
</container>
|
</container>
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
</service>
|
</service>
|
||||||
<service id="knp_gaufrette.adapter.amazon_s3" class="Gaufrette\Adapter\AmazonS3" abstract="true" public="false" />
|
<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.acl_aware_amazon_s3" class="Gaufrette\Adapter\AclAwareAmazonS3" abstract="true" public="false" />
|
||||||
|
<service id="knp_gaufrette.adapter.gridfs" class="Gaufrette\Adapter\GridFS" abstract="true" public="false" />
|
||||||
<service id="knp_gaufrette.filesystem_map" class="Knp\Bundle\GaufretteBundle\FilesystemMap">
|
<service id="knp_gaufrette.filesystem_map" class="Knp\Bundle\GaufretteBundle\FilesystemMap">
|
||||||
<argument /> <!-- map of filesystems -->
|
<argument /> <!-- map of filesystems -->
|
||||||
</service>
|
</service>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user