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

Breadcrumb

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

class DirectoryLoader

Same name in this branch
  1. 11.1.x vendor/symfony/routing/Loader/DirectoryLoader.php \Symfony\Component\Routing\Loader\DirectoryLoader

DirectoryLoader is a recursive loader to go through directories.

@author Sebastien Lavoie <seb@wemakecustom.com>

Hierarchy

  • class \Symfony\Component\DependencyInjection\Loader\FileLoader extends \Symfony\Component\Config\Loader\FileLoader
    • class \Symfony\Component\DependencyInjection\Loader\DirectoryLoader extends \Symfony\Component\DependencyInjection\Loader\FileLoader

Expanded class hierarchy of DirectoryLoader

2 files declare their use of DirectoryLoader
ExtensionTrait.php in vendor/symfony/dependency-injection/Extension/ExtensionTrait.php
Kernel.php in vendor/symfony/http-kernel/Kernel.php

File

vendor/symfony/dependency-injection/Loader/DirectoryLoader.php, line 19

Namespace

Symfony\Component\DependencyInjection\Loader
View source
class DirectoryLoader extends FileLoader {
    public function load(mixed $file, ?string $type = null) : mixed {
        $file = rtrim($file, '/');
        $path = $this->locator
            ->locate($file);
        $this->container
            ->fileExists($path, false);
        foreach (scandir($path) as $dir) {
            if ('.' !== $dir[0]) {
                if (is_dir($path . '/' . $dir)) {
                    $dir .= '/';
                    // append / to allow recursion
                }
                $this->setCurrentDir($path);
                $this->import($dir, null, false, $path);
            }
        }
        return null;
    }
    public function supports(mixed $resource, ?string $type = null) : bool {
        if ('directory' === $type) {
            return true;
        }
        return null === $type && \is_string($resource) && str_ends_with($resource, '/');
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
DirectoryLoader::load public function
DirectoryLoader::supports public function
FileLoader::$aliases protected property @var array&lt;string, Alias&gt;
FileLoader::$autoRegisterAliasesForSinglyImplementedInterfaces protected property 3
FileLoader::$extensionConfigs protected property
FileLoader::$importing protected property
FileLoader::$instanceof protected property
FileLoader::$interfaces protected property
FileLoader::$isLoadingInstanceof protected property
FileLoader::$singlyImplemented protected property
FileLoader::addContainerExcludedTag private function
FileLoader::ANONYMOUS_ID_REGEXP public constant
FileLoader::findClasses private function
FileLoader::import public function
FileLoader::loadExtensionConfig final protected function
FileLoader::loadExtensionConfigs final protected function
FileLoader::registerAliasesForSinglyImplementedInterfaces public function
FileLoader::registerClasses public function Registers a set of classes as services using PSR-4 for discovery.
FileLoader::setDefinition protected function Registers a definition in the container with its instanceof-conditionals.
FileLoader::__construct public function 1
RSS feed
Powered by Drupal