Skip to content

Commit 918e5c9

Browse files
Added doc and test
1 parent d86bff2 commit 918e5c9

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,16 @@ liip_imagine:
382382
data_root: /path/to/source/images/dir
383383
```
384384

385-
This location must be readable by your web server. On a system that supports
385+
When you need assets from bundles which have a `Resources/public`-folder, you can automatically add them to the `data_root` by setting the `bundle_resources` parameter to `true`.
386+
```yml
387+
liip_imagine:
388+
loaders:
389+
default:
390+
filesystem:
391+
bundle_resources: true
392+
```
393+
394+
Image locations must be readable by your web server. On a system that supports
386395
`setfacl` (such as Linux/BSD), use
387396

388397
```sh

Resources/doc/data-loader/filesystem.rst

+14
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,17 @@ You can configure the ``data_root``, used as the root path to search for images:
3636
profile_photos:
3737
filesystem:
3838
data_root: "%kernel.root_dir%/../web"
39+
40+
You can automatically load bundle resources in their ``Resources/public`` by enabling
41+
the ``bundle_resources`` parameter. This will automatically add those directories to the
42+
root path.
43+
44+
.. code-block:: yaml
45+
46+
# app/config/config.yml
47+
48+
liip_imagine:
49+
loaders:
50+
profile_photos:
51+
filesystem:
52+
bundle_resources: true

Tests/DependencyInjection/Factory/Loader/FileSystemLoaderFactoryTest.php

+23-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public function testCreateLoaderDefinitionOnCreate()
4848
$loader = new FileSystemLoaderFactory();
4949

5050
$loader->create($container, 'the_loader_name', array(
51-
'data_root' => 'theDataRoot',
51+
'bundle_resources' => false,
52+
'data_root' => array('theDataRoot'),
5253
'locator' => 'filesystem',
5354
));
5455

@@ -59,7 +60,27 @@ public function testCreateLoaderDefinitionOnCreate()
5960
$this->assertInstanceOfChildDefinition($loaderDefinition);
6061
$this->assertEquals('liip_imagine.binary.loader.prototype.filesystem', $loaderDefinition->getParent());
6162

62-
$this->assertEquals('theDataRoot', $loaderDefinition->getArgument(2));
63+
$this->assertEquals(array('theDataRoot'), $loaderDefinition->getArgument(2));
64+
}
65+
66+
public function testCreateLoaderDefinitionOnCreateWithBundlesEnabled()
67+
{
68+
$container = new ContainerBuilder();
69+
70+
// We need at least an empty bundle parameter
71+
$container->setParameter('kernel.bundles', array());
72+
73+
$loader = new FileSystemLoaderFactory();
74+
75+
$loader->create($container, 'the_loader_name', array(
76+
'bundle_resources' => true,
77+
'data_root' => array('theDataRoot'),
78+
'locator' => 'filesystem',
79+
));
80+
81+
$loaderDefinition = $container->getDefinition('liip_imagine.binary.loader.the_loader_name');
82+
83+
$this->assertEquals(array('theDataRoot'), $loaderDefinition->getArgument(2));
6384
}
6485

6586
public function testProcessCorrectlyOptionsOnAddConfiguration()

0 commit comments

Comments
 (0)