class PhpFileLoader
Same name in this branch
- 11.1.x vendor/symfony/dependency-injection/Loader/PhpFileLoader.php \Symfony\Component\DependencyInjection\Loader\PhpFileLoader
PhpFileLoader loads routes from a PHP file.
The file must return a RouteCollection instance.
@author Fabien Potencier <fabien@symfony.com> @author Nicolas grekas <p@tchwork.com> @author Jules Pietri <jules@heahprod.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
- RoutingConfigurator.php in vendor/
symfony/ routing/ Loader/ Configurator/ RoutingConfigurator.php
File
-
vendor/
symfony/ routing/ Loader/ PhpFileLoader.php, line 28
Namespace
Symfony\Component\Routing\LoaderView source
class PhpFileLoader extends FileLoader {
/**
* Loads a PHP file.
*/
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;
}
public function supports(mixed $resource, ?string $type = null) : bool {
return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'php' === $type);
}
protected function callConfigurator(callable $result, string $path, string $file) : RouteCollection {
$collection = new RouteCollection();
$result(new RoutingConfigurator($collection, $this, $path, $file, $this->env));
return $collection;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
PhpFileLoader::callConfigurator | protected | function | |
PhpFileLoader::load | public | function | Loads a PHP file. |
PhpFileLoader::supports | public | function |