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

Breadcrumb

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

function FileLoader::import

Parameters

bool|string $ignoreErrors Whether errors should be ignored; pass "not_found" to ignore only when the loaded resource is not found:

4 calls to FileLoader::import()
DirectoryLoader::load in vendor/symfony/dependency-injection/Loader/DirectoryLoader.php
GlobFileLoader::load in vendor/symfony/dependency-injection/Loader/GlobFileLoader.php
XmlFileLoader::parseImports in vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
YamlFileLoader::parseImports in vendor/symfony/dependency-injection/Loader/YamlFileLoader.php

File

vendor/symfony/dependency-injection/Loader/FileLoader.php, line 66

Class

FileLoader
FileLoader is the abstract class used by all built-in loaders that are file based.

Namespace

Symfony\Component\DependencyInjection\Loader

Code

public function import(mixed $resource, ?string $type = null, bool|string $ignoreErrors = false, ?string $sourceResource = null, $exclude = null) : mixed {
    $args = \func_get_args();
    if ($ignoreNotFound = 'not_found' === $ignoreErrors) {
        $args[2] = false;
    }
    elseif (!\is_bool($ignoreErrors)) {
        throw new \TypeError(\sprintf('Invalid argument $ignoreErrors provided to "%s::import()": boolean or "not_found" expected, "%s" given.', static::class, get_debug_type($ignoreErrors)));
    }
    ++$this->importing;
    try {
        return parent::import(...$args);
    } catch (LoaderLoadException $e) {
        if (!$ignoreNotFound || !($prev = $e->getPrevious()) instanceof FileLocatorFileNotFoundException) {
            throw $e;
        }
        foreach ($prev->getTrace() as $frame) {
            if ('import' === ($frame['function'] ?? null) && is_a($frame['class'] ?? '', Loader::class, true)) {
                break;
            }
        }
        if (__FILE__ !== $frame['file']) {
            throw $e;
        }
    } finally {
        --$this->importing;
        $this->loadExtensionConfigs();
    }
    return null;
}

API Navigation

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