vendor/knplabs/knp-gaufrette-bundle/FilesystemMap.php line 58

Open in your IDE?
  1. <?php
  2. namespace Knp\Bundle\GaufretteBundle;
  3. use Gaufrette\FilesystemMapInterface;
  4. /**
  5.  * Holds references to all declared filesystems
  6.  * and allows to access them through their name.
  7.  */
  8. class FilesystemMap implements \IteratorAggregateFilesystemMapInterface
  9. {
  10.     /**
  11.      * Map of filesystems indexed by their name.
  12.      *
  13.      * @var array
  14.      */
  15.     protected $maps;
  16.     /**
  17.      * Instantiates a new filesystem map.
  18.      *
  19.      * @param array $maps
  20.      */
  21.     public function __construct(array $maps)
  22.     {
  23.         $this->maps $maps;
  24.     }
  25.     /**
  26.      * Retrieves a filesystem by its name.
  27.      *
  28.      * @param string $name name of a filesystem
  29.      *
  30.      * @return \Gaufrette\Filesystem
  31.      *
  32.      * @throw \InvalidArgumentException if the filesystem does not exist
  33.      */
  34.     public function get($name)
  35.     {
  36.         if (!$this->has($name)) {
  37.             throw new \InvalidArgumentException(sprintf('No filesystem is registered for name "%s"'$name));
  38.         }
  39.         return $this->maps[$name];
  40.     }
  41.     /**
  42.      * @param string $name name of a filesystem
  43.      *
  44.      * @return bool
  45.      */
  46.     public function has($name)
  47.     {
  48.         return isset($this->maps[$name]);
  49.     }
  50.     public function getIterator()
  51.     {
  52.         return new \ArrayIterator($this->maps);
  53.     }
  54. }