function PhpFileLoader::load
Same name in this branch
- 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\LoaderCode
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;
}