vendor/knplabs/knp-gaufrette-bundle/KnpGaufretteBundle.php line 14

Open in your IDE?
  1. <?php
  2. namespace Knp\Bundle\GaufretteBundle;
  3. use Symfony\Component\DependencyInjection\ContainerBuilder;
  4. use Symfony\Component\HttpKernel\Bundle\Bundle;
  5. use Gaufrette\StreamWrapper;
  6. /**
  7. * The Gaufrette Bundle
  8. *
  9. * @author Antoine Hérault <antoine.herault@gmail.com>
  10. */
  11. class KnpGaufretteBundle extends Bundle
  12. {
  13. public function boot()
  14. {
  15. parent::boot();
  16. if (!$this->container->hasParameter('knp_gaufrette.stream_wrapper.protocol')
  17. || !$this->container->hasParameter('knp_gaufrette.stream_wrapper.filesystems')) {
  18. return;
  19. }
  20. StreamWrapper::register($this->container->getParameter('knp_gaufrette.stream_wrapper.protocol'));
  21. $wrapperFsMap = StreamWrapper::getFilesystemMap();
  22. $fileSystems = $this->container->getParameter('knp_gaufrette.stream_wrapper.filesystems');
  23. /*
  24. * If there are no filesystems configured to be wrapped,
  25. * all filesystems within the map will be wrapped.
  26. */
  27. if (empty($fileSystems)) {
  28. $fileSystems = $this->container->get('knp_gaufrette.filesystem_map');
  29. foreach ($fileSystems as $domain => $fileSystem) {
  30. $wrapperFsMap->set($domain, $fileSystem);
  31. }
  32. } else {
  33. foreach ($fileSystems as $domain => $fileSystem) {
  34. $wrapperFsMap->set($domain, $this->container->get('knp_gaufrette.filesystem_map')->get($fileSystem));
  35. }
  36. }
  37. }
  38. }