You are here

class PhpFileLoader in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/routing/Loader/PhpFileLoader.php \Symfony\Component\Routing\Loader\PhpFileLoader
  2. 8 vendor/symfony/translation/Loader/PhpFileLoader.php \Symfony\Component\Translation\Loader\PhpFileLoader
  3. 8 vendor/symfony/dependency-injection/Loader/PhpFileLoader.php \Symfony\Component\DependencyInjection\Loader\PhpFileLoader
Same name and namespace in other branches
  1. 8.0 vendor/symfony/routing/Loader/PhpFileLoader.php \Symfony\Component\Routing\Loader\PhpFileLoader

PhpFileLoader loads routes from a PHP file.

The file must return a RouteCollection instance.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

  • class \Symfony\Component\Routing\Loader\PhpFileLoader extends \Symfony\Component\Config\Loader\FileLoader

Expanded class hierarchy of PhpFileLoader

1 file declares its use of PhpFileLoader
PhpFileLoaderTest.php in vendor/symfony/routing/Tests/Loader/PhpFileLoaderTest.php
1 string reference to 'PhpFileLoader'
TranslatorTest::getTransFileTests in vendor/symfony/translation/Tests/TranslatorTest.php

File

vendor/symfony/routing/Loader/PhpFileLoader.php, line 25

Namespace

Symfony\Component\Routing\Loader
View source
class PhpFileLoader extends FileLoader {

  /**
   * Loads a PHP file.
   *
   * @param string      $file A PHP file path
   * @param string|null $type The resource type
   *
   * @return RouteCollection A RouteCollection instance
   */
  public function load($file, $type = null) {
    $path = $this->locator
      ->locate($file);
    $this
      ->setCurrentDir(dirname($path));
    $collection = self::includeFile($path, $this);
    $collection
      ->addResource(new FileResource($path));
    return $collection;
  }

  /**
   * {@inheritdoc}
   */
  public function supports($resource, $type = null) {
    return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type);
  }

  /**
   * Safe include. Used for scope isolation.
   *
   * @param string        $file   File to include
   * @param PhpFileLoader $loader the loader variable is exposed to the included file below
   *
   * @return RouteCollection
   */
  private static function includeFile($file, PhpFileLoader $loader) {
    return include $file;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpFileLoader::includeFile private static function Safe include. Used for scope isolation.
PhpFileLoader::load public function Loads a PHP file.
PhpFileLoader::supports public function