public function PhpFileLoader::load

Same name in this branch

Loads a PHP file.

@api

Parameters

string $file A PHP file path:

string|null $type The resource type:

Return value

RouteCollection A RouteCollection instance

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php, line 39

Class

PhpFileLoader
PhpFileLoader loads routes from a PHP file.

Namespace

Symfony\Component\Routing\Loader

Code

public function load($file, $type = null) {

  // the loader variable is exposed to the included file below
  $loader = $this;
  $path = $this->locator
    ->locate($file);
  $this
    ->setCurrentDir(dirname($path));
  $collection = (include $path);
  $collection
    ->addResource(new FileResource($path));
  return $collection;
}