diff --git a/DependencyInjection/Factory/DoctrineDbalAdapterFactory.php b/DependencyInjection/Factory/DoctrineDbalAdapterFactory.php
new file mode 100644
index 0000000..e604042
--- /dev/null
+++ b/DependencyInjection/Factory/DoctrineDbalAdapterFactory.php
@@ -0,0 +1,61 @@
+
+ */
+class DoctrineDbalAdapterFactory implements AdapterFactoryInterface
+{
+ /**
+ * {@inheritDoc}
+ */
+ function create(ContainerBuilder $container, $id, array $config)
+ {
+ $definition = $container
+ ->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.doctrine_dbal'))
+ ->addArgument(new Reference('doctrine.dbal.' . $config['connection_name'] . '_connection'))
+ ->addArgument($config['table'])
+ ;
+
+ if (isset($config['columns'])) {
+ $definition->addArgument($config['columns']);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ function getKey()
+ {
+ return 'doctrine_dbal';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ function addConfiguration(NodeDefinition $builder)
+ {
+ $builder
+ ->children()
+ ->scalarNode('connection_name')->isRequired()->cannotBeEmpty()->end()
+ ->scalarNode('table')->isRequired()->cannotBeEmpty()->end()
+ ->arrayNode('columns')
+ ->children()
+ ->scalarNode('key')->end()
+ ->scalarNode('content')->end()
+ ->scalarNode('mtime')->end()
+ ->scalarNode('checksum')->end()
+ ->end()
+ ->end()
+ ->end()
+ ;
+ }
+}
diff --git a/README.markdown b/README.markdown
index 9542381..e7c85c8 100644
--- a/README.markdown
+++ b/README.markdown
@@ -43,7 +43,7 @@ This bundle can be installed using composer by adding the following in the `requ
...
"knplabs/knp-gaufrette-bundle": "dev-master"
},
-```
+```
### Git Submodule Style
@@ -51,7 +51,7 @@ If you are versioning your project with git and making changes to this bundle yo
$ git submodule add https://github.com/KnpLabs/KnpGaufretteBundle.git vendor/bundles/Knp/Bundle/GaufretteBundle
-## Add the namespace in the autoloader
+## Add the namespace in the autoloader
You must register both Gaufrette and the KnpGaufretteBundle in your autoloader:
(You do not have to do this if you are using the composer autoload system.)
@@ -61,7 +61,7 @@ You must register both Gaufrette and the KnpGaufretteBundle in your autoloader:
// app/autoload.php
-$loader->registerNamespaces(array(
+$loader->addClassMap(array(
'Knp\Bundle' => __DIR__.'/../vendor/bundles',
'Gaufrette' => __DIR__.'/../vendor/gaufrette/src',
// ...
@@ -463,7 +463,7 @@ Note that Gaufrette is not currently compatible with the v2 Amazon SDK (called "
### Defining services
-To use the Amazon S3 adapter you need to provide a valid `AmazonS3` instance (as defined in the Amazon SDK). This can
+To use the Amazon S3 adapter you need to provide a valid `AmazonS3` instance (as defined in the Amazon SDK). This can
easily be set up as using Symfony's service configuration:
``` yaml
@@ -475,7 +475,7 @@ services:
options:
key: '%aws_key%'
secret: '%aws_secret_key%'
-```
+```
### Example
@@ -505,11 +505,11 @@ Adapter for OpenCloud (Rackspace)
* `container_name`: the name of the container to use
* `create_container`: if `true` will create the container if it doesn't exist *(default `false`)*
* `detect_content_type`: if `true` will detect the content type for each file *(default `true`)*
-
+
### Defining services
To use the OpenCloud adapter you should provide a valid `ObjectStore` instance. You can retrieve an instance through the
-`OpenCloud\OpenStack` or `OpenCloud\Rackspace` instances. We can provide a comprehensive configuration through the Symfony
+`OpenCloud\OpenStack` or `OpenCloud\Rackspace` instances. We can provide a comprehensive configuration through the Symfony
DIC configuration.
#### Define OpenStack/Rackspace service
@@ -563,7 +563,7 @@ services:
factory_service: opencloud.connection.hpcloud
factory_method: ObjectStore
arguments:
- - 'Object Storage' # Object storage type
+ - 'Object Storage' # Object storage type
- 'region-a.geo-1' # Object storage region
- 'publicURL' # url type
```
@@ -578,7 +578,7 @@ services:
factory_service: opencloud.connection
factory_method: ObjectStore
arguments:
- - 'cloudFiles' # Object storage type
+ - 'cloudFiles' # Object storage type
- 'DFW' # Object storage region
- 'publicURL' # url type
```
@@ -638,14 +638,14 @@ knp_gaufrette:
## Stream Wrapper
-The `stream_wrapper` settings allow you to register filesystems with a specified domain and
+The `stream_wrapper` settings allow you to register filesystems with a specified domain and
then use as a stream wrapper anywhere in your code like:
`gaufrette://domain/file.txt`
### Parameters
* `protocol` The protocol name like `gaufrette://…` *(default gaufrette)*
- * `filesystem` An array that contains filesystems that you want to register to this stream_wrapper.
+ * `filesystem` An array that contains filesystems that you want to register to this stream_wrapper.
If you set array keys these will be used as an alias for the filesystem (see examples below) *(default all filesystems without aliases)*
### Example 1
@@ -735,4 +735,35 @@ data://backup/...
data://pictures/...
```
+## Doctrine DBAL (doctrine_dbal)
+
+Adapter that allows you to store data into a database.
+
+### Parameters
+
+ * `connection_name` The doctrine dbal connection name like `default`
+ * `table` The table name like `media_data`
+ * `key`: The primary key in the table
+ * `content`: The field name of the file content
+ * `mtime`: The field name of the timestamp
+ * `checksum`: The field name of the checksum
+
+### Example
+
+``` yaml
+# app/config/config.yml
+knp_gaufrette:
+ adapters:
+ database:
+ doctrine_dbal:
+ connection_name: default
+ table: data
+ columns:
+ key: id
+ content: text
+ mtime: date
+ checksum: checksum
+```
+
[gaufrette-homepage]: https://github.com/KnpLabs/Gaufrette
+
diff --git a/Resources/config/adapter_factories.xml b/Resources/config/adapter_factories.xml
index 6ae6efe..28ae34c 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 f80c01c..3c08ac0 100644
--- a/Resources/config/gaufrette.xml
+++ b/Resources/config/gaufrette.xml
@@ -23,6 +23,7 @@
+