Documentation

Storage configuration

Integrated allows to put files on one or multiple storages, that can be local, on the cloud or any other place supported by a Gaufrette adaptor. 

Basic configuration

Integrated makes use of knplabs/knp-gaufrette-bundle for configuration and a filesystem map. When you've enabled the bundle this config below is required for a default Integrated installation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<pre>// app/config.yml
knp_gaufrette:
    adapters:
        foo:
            local:
                directory: %kernel.root_dir%/../web/uploads/documents
    filesystems:
        foo:
            adapter: foo
 
integrated_storage:
    resolver:
        foo:
            public: /files</pre>

Please see the KnpGaufretteBundle documentation for all available options.

Using multiple filesystems

The StorageBundle places the files on all known filesystems when no decision mapping exists. The order defined in the configuration will be used to determine its primary path.

Storage resolver

When a filesystem has no resolver storage (for protected files) components which use the public URL will not be able to access the file. The filesystems (foo above) in the knp_gaufrette configuration are linked to the integrated_storage configuration. Based on the key(s) a resolver or decision map entry is linked to a filesystem.

Using a decision map

Additionally to protected entities from being stored in a public accessible resource a developer can configure filesystems for entities. You can enforce entities to be stored in specific storage(s).

 
1
2
3
4
5
<pre>// app/config.yml
integrated_storage:
    // ...
    decision_map:
        "Integrated\Bundle\ContentBundle\Document\File": [foo]</pre>

The redistribution command does not make use of the decision map and copies all files in the given storage.

Protecting files

In some cases the files may not be stored in a public available directory. Most cases a directory on the home of the user is enough which can be stored local. You can do this by adding an additional private local storage. However files can also be stored on any remote by not defining an resolver.

A controller might look like the following:

1
2
3
4
<pre><span class="x">// File is a Integrated\Common\Content\Document\FileInterface object    </span>
<span class="p">$</span><span class="nv">response</span><span class="x"> = new Response();</span>
<span class="p">$</span><span class="nv">response</span><span class="x">->setContent(</span><span class="p">$</span><span class="nv">file</span><span class="x">->getContent());</span>
<span class="p">$</span><span class="nv">response</span><span class="x">->setHeaders(</span><span class="p">$</span><span class="nv">file</span><span class="x">->getMetadata()->getHeaders());</span></pre>