[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/symfony/routing/Symfony/Component/Routing/Loader/ -> PhpFileLoader.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\FileResource;
  16  use Symfony\Component\Routing\RouteCollection;
  17  
  18  /**
  19   * PhpFileLoader loads routes from a PHP file.
  20   *
  21   * The file must return a RouteCollection instance.
  22   *
  23   * @author Fabien Potencier <fabien@symfony.com>
  24   */
  25  class PhpFileLoader extends FileLoader
  26  {
  27      /**
  28       * Loads a PHP file.
  29       *
  30       * @param string      $file A PHP file path
  31       * @param string|null $type The resource type
  32       *
  33       * @return RouteCollection A RouteCollection instance
  34       */
  35      public function load($file, $type = null)
  36      {
  37          // the loader variable is exposed to the included file below
  38          $loader = $this;
  39  
  40          $path = $this->locator->locate($file);
  41          $this->setCurrentDir(dirname($path));
  42  
  43          $collection = include $path;
  44          $collection->addResource(new FileResource($path));
  45  
  46          return $collection;
  47      }
  48  
  49      /**
  50       * {@inheritdoc}
  51       */
  52      public function supports($resource, $type = null)
  53      {
  54          return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type);
  55      }
  56  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1