Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PhpFileLoader.php

function PhpFileLoader::load

Same name in this branch
  1. 11.1.x vendor/symfony/dependency-injection/Loader/PhpFileLoader.php \Symfony\Component\DependencyInjection\Loader\PhpFileLoader::load()

Loads a PHP file.

File

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

Class

PhpFileLoader
PhpFileLoader loads routes from a PHP file.

Namespace

Symfony\Component\Routing\Loader

Code

public function load(mixed $file, ?string $type = null) : RouteCollection {
    $path = $this->locator
        ->locate($file);
    $this->setCurrentDir(\dirname($path));
    // the closure forbids access to the private scope in the included file
    $loader = $this;
    $load = \Closure::bind(static function ($file) use ($loader) {
        return include $file;
    }, null, ProtectedPhpFileLoader::class);
    $result = $load($path);
    if (\is_object($result) && \is_callable($result)) {
        $collection = $this->callConfigurator($result, $path, $file);
    }
    else {
        $collection = $result;
    }
    $collection->addResource(new FileResource($path));
    return $collection;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal