Merge pull request #6 from Rohea/master

MogileFS support
This commit is contained in:
Antoine Hérault 2011-11-08 09:38:58 -08:00
commit 7e3596e5b6
4 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,52 @@
<?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 Mikko Tarvainen 2011 <mtarvainen@gmail.com>
*/
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()
;
}
}

View File

@ -221,7 +221,7 @@ knp_gaufrette:
## GridFS (gridfs) ## GridFS (gridfs)
Allows you to use a gridfs as an adapter. Adapter that allows you to use a MongoDB GridFS for storing files.
### Parameters ### Parameters
@ -260,5 +260,27 @@ services:
arguments: [@acme_test.mongodb, %acme_test.gridfs.prefix%] 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 [gaufrette-homepage]: https://github.com/knplabs/Gaufrette

View File

@ -26,6 +26,10 @@
<service id="knp_gaufrette.adapter.factory.gridfs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\GridFSAdapterFactory"> <service id="knp_gaufrette.adapter.factory.gridfs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\GridFSAdapterFactory">
<tag name="gaufrette.adapter.factory" /> <tag name="gaufrette.adapter.factory" />
</service> </service>
<service id="knp_gaufrette.adapter.factory.mogilefs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\MogileFSAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
</services> </services>
</container> </container>

View File

@ -22,6 +22,10 @@
<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.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 -->
<argument /><!-- hosts -->
</service>
<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>