From f4e362c1b58b07bf6156eedbe57a30ef7ce87a6c Mon Sep 17 00:00:00 2001 From: Tomi Saarinen Date: Mon, 3 Oct 2011 15:59:23 +0300 Subject: [PATCH 1/3] GridFS support --- .../Factory/GridFSAdapterFactory.php | 47 +++++++++++++++++++ Resources/config/adapter_factories.xml | 3 ++ Resources/config/gaufrette.xml | 1 + 3 files changed, 51 insertions(+) create mode 100644 DependencyInjection/Factory/GridFSAdapterFactory.php diff --git a/DependencyInjection/Factory/GridFSAdapterFactory.php b/DependencyInjection/Factory/GridFSAdapterFactory.php new file mode 100644 index 0000000..b310562 --- /dev/null +++ b/DependencyInjection/Factory/GridFSAdapterFactory.php @@ -0,0 +1,47 @@ + + */ +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() + ; + } +} diff --git a/Resources/config/adapter_factories.xml b/Resources/config/adapter_factories.xml index 449b21a..3de8c03 100644 --- a/Resources/config/adapter_factories.xml +++ b/Resources/config/adapter_factories.xml @@ -23,6 +23,9 @@ + + + diff --git a/Resources/config/gaufrette.xml b/Resources/config/gaufrette.xml index 2d9b800..6aabbd1 100644 --- a/Resources/config/gaufrette.xml +++ b/Resources/config/gaufrette.xml @@ -21,6 +21,7 @@ + From 978d3a22e4cde80948f41aa1e884ebfe3f9e90e5 Mon Sep 17 00:00:00 2001 From: Tomi Saarinen Date: Mon, 3 Oct 2011 16:11:44 +0300 Subject: [PATCH 2/3] docs --- README.markdown | 51 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 68b2761..3a69baf 100644 --- a/README.markdown +++ b/README.markdown @@ -141,7 +141,7 @@ A simple local filesystem based adapter. * `directory` The directory of the filesystem *(required)* * `create` Whether to create the directory if it does not exist *(default true)* -### Exemple +### Example ``` yaml # 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)* * `create` Whether to create the directory if it does not exist *(default true)* -### Exemple +### Example ``` yaml # app/config/config.yml @@ -182,7 +182,7 @@ Allows you to use a user defined adapter service. * `id` The id of the service *(required)* -### Exemple +### Example ``` yaml # 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. -### Exemple +### Example ``` yaml # app/config/config.yml @@ -219,4 +219,47 @@ knp_gaufrette: 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/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 From 25f10320799d31f65ae946268b94e4cbab5ce867 Mon Sep 17 00:00:00 2001 From: Tomi Saarinen Date: Mon, 3 Oct 2011 16:19:08 +0300 Subject: [PATCH 3/3] small fix to docs --- README.markdown | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 3a69baf..6be0562 100644 --- a/README.markdown +++ b/README.markdown @@ -241,7 +241,7 @@ knp_gaufrette: In your AcmeTestBundle, add following service definitions: ``` yaml -# src/Acme/TestBundle/services.yml +# src/Acme/TestBundle/Resources/config/services.yml parameters: acme_test.mongo.server: "mongodb://localhost:27017" acme_test.mongo.options: @@ -261,5 +261,4 @@ services: ``` - [gaufrette-homepage]: https://github.com/knplabs/Gaufrette