Boot filesystems for a specified domain

This commit is contained in:
bertillon clement
2012-10-10 17:32:37 +02:00
parent 790652531f
commit 237055ef01
8 changed files with 252 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ namespace Knp\Bundle\GaufretteBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Gaufrette\StreamWrapper;
/**
* The Gaufrette Bundle
@@ -12,4 +13,26 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
*/
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 (empty($fileSystems)) {
$fileSystems = $this->container->get('knp_gaufrette.filesystem_map');
}
foreach ($fileSystems as $domain => $fileSystem) {
$wrapperFsMap->set($domain, $this->container->get('knp_gaufrette.filesystem_map')->get($fileSystem));
}
}
}