function DirectoryLoader::load
Same name in this branch
- 11.1.x vendor/symfony/dependency-injection/Loader/DirectoryLoader.php \Symfony\Component\DependencyInjection\Loader\DirectoryLoader::load()
File
-
vendor/
symfony/ routing/ Loader/ DirectoryLoader.php, line 20
Class
Namespace
Symfony\Component\Routing\LoaderCode
public function load(mixed $file, ?string $type = null) : mixed {
$path = $this->locator
->locate($file);
$collection = new RouteCollection();
$collection->addResource(new DirectoryResource($path));
foreach (scandir($path) as $dir) {
if ('.' !== $dir[0]) {
$this->setCurrentDir($path);
$subPath = $path . '/' . $dir;
$subType = null;
if (is_dir($subPath)) {
$subPath .= '/';
$subType = 'directory';
}
$subCollection = $this->import($subPath, $subType, false, $path);
$collection->addCollection($subCollection);
}
}
return $collection;
}