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

Breadcrumb

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

function DirectoryLoader::load

Same name in this branch
  1. 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

DirectoryLoader

Namespace

Symfony\Component\Routing\Loader

Code

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;
}

API Navigation

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