[ Index ]

PHP Cross Reference of phpBB-3.3.5-deutsch

title

Body

[close]

/vendor/symfony/routing/Loader/ -> DirectoryLoader.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\Routing\Loader;
  13  
  14  use Symfony\Component\Config\Loader\FileLoader;
  15  use Symfony\Component\Config\Resource\DirectoryResource;
  16  use Symfony\Component\Routing\RouteCollection;
  17  
  18  class DirectoryLoader extends FileLoader
  19  {
  20      /**
  21       * {@inheritdoc}
  22       */
  23      public function load($file, $type = null)
  24      {
  25          $path = $this->locator->locate($file);
  26  
  27          $collection = new RouteCollection();
  28          $collection->addResource(new DirectoryResource($path));
  29  
  30          foreach (scandir($path) as $dir) {
  31              if ('.' !== $dir[0]) {
  32                  $this->setCurrentDir($path);
  33                  $subPath = $path.'/'.$dir;
  34                  $subType = null;
  35  
  36                  if (is_dir($subPath)) {
  37                      $subPath .= '/';
  38                      $subType = 'directory';
  39                  }
  40  
  41                  $subCollection = $this->import($subPath, $subType, false, $path);
  42                  $collection->addCollection($subCollection);
  43              }
  44          }
  45  
  46          return $collection;
  47      }
  48  
  49      /**
  50       * {@inheritdoc}
  51       */
  52      public function supports($resource, $type = null)
  53      {
  54          // only when type is forced to directory, not to conflict with AnnotationLoader
  55  
  56          return 'directory' === $type;
  57      }
  58  }


Generated: Mon Oct 4 17:42:11 2021 Cross-referenced by PHPXref 0.7.1