diff --git a/DependencyInjection/Factory/MogileFSAdapterFactory.php b/DependencyInjection/Factory/MogileFSAdapterFactory.php new file mode 100644 index 0000000..19b956b --- /dev/null +++ b/DependencyInjection/Factory/MogileFSAdapterFactory.php @@ -0,0 +1,52 @@ + + */ +class MogileFSAdapterFactory implements AdapterFactoryInterface +{ + /** + * {@inheritDoc} + */ + public function create(ContainerBuilder $container, $id, array $config) + { + $container + ->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.mogilefs')) + ->replaceArgument(0, $config['domain']) + ->replaceArgument(1, $config['hosts']) + ; + } + + /** + * {@inheritDoc} + */ + public function getKey() + { + return 'mogilefs'; + } + + /** + * {@inheritDoc} + */ + public function addConfiguration(NodeDefinition $node) + { + $node + ->children() + ->scalarNode('domain')->isRequired()->cannotBeEmpty()->end() + ->arrayNode('hosts') + ->requiresAtLeastOneElement() + ->prototype('scalar')->end() + ->end() + ->end() + ; + } +} diff --git a/README.markdown b/README.markdown index 6be0562..5e7319c 100644 --- a/README.markdown +++ b/README.markdown @@ -221,7 +221,7 @@ knp_gaufrette: ## GridFS (gridfs) -Allows you to use a gridfs as an adapter. +Adapter that allows you to use a MongoDB GridFS for storing files. ### Parameters @@ -260,5 +260,27 @@ services: arguments: [@acme_test.mongodb, %acme_test.gridfs.prefix%] ``` +Note that it is possible to prepare MongoGridFS service anyway you like. This is just one way to do it. + +## MogileFS (mogilefs) + +Adapter that allows you to use MogileFS for storing files. + +### Parameters + + * `domain` MogileFS domain + * `hosts` Available trackers + +### Example + +``` yaml +# app/config/config.yml +knp_gaufrette: + adapters: + foo: + mogilefs: + domain: foobar + hosts: ["192.168.0.1:7001", "192.168.0.2:7001"] +``` [gaufrette-homepage]: https://github.com/knplabs/Gaufrette diff --git a/Resources/config/adapter_factories.xml b/Resources/config/adapter_factories.xml index 3de8c03..08668a9 100644 --- a/Resources/config/adapter_factories.xml +++ b/Resources/config/adapter_factories.xml @@ -26,6 +26,10 @@ + + + + diff --git a/Resources/config/gaufrette.xml b/Resources/config/gaufrette.xml index 6aabbd1..ecb16b8 100644 --- a/Resources/config/gaufrette.xml +++ b/Resources/config/gaufrette.xml @@ -22,6 +22,10 @@ + + + +