forked from KnpLabs/KnpGaufretteBundle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
KnpGaufretteBundle.php
45 lines (38 loc) · 1.45 KB
/
KnpGaufretteBundle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Knp\Bundle\GaufretteBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Gaufrette\StreamWrapper;
/**
* The Gaufrette Bundle
*
* @author Antoine Hérault <[email protected]>
*/
class KnpGaufretteBundle extends Bundle
{
public function boot()
{
parent::boot();
if (!$this->container->hasParameter('knp_gaufrette.stream_wrapper.protocol')
|| !$this->container->hasParameter('knp_gaufrette.stream_wrapper.filesystems')) {
return;
}
StreamWrapper::register($this->container->getParameter('knp_gaufrette.stream_wrapper.protocol'));
$wrapperFsMap = StreamWrapper::getFilesystemMap();
$fileSystems = $this->container->getParameter('knp_gaufrette.stream_wrapper.filesystems');
/*
* If there are no filesystems configured to be wrapped,
* all filesystems within the map will be wrapped.
*/
if (empty($fileSystems)) {
$fileSystems = $this->container->get('knp_gaufrette.filesystem_map');
foreach ($fileSystems as $domain => $fileSystem) {
$wrapperFsMap->set($domain, $fileSystem);
}
} else {
foreach ($fileSystems as $domain => $fileSystem) {
$wrapperFsMap->set($domain, $this->container->get('knp_gaufrette.filesystem_map')->get($fileSystem));
}
}
}
}