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

Breadcrumb

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

function IniFileLoader::load

File

vendor/symfony/dependency-injection/Loader/IniFileLoader.php, line 24

Class

IniFileLoader
IniFileLoader loads parameters from INI files.

Namespace

Symfony\Component\DependencyInjection\Loader

Code

public function load(mixed $resource, ?string $type = null) : mixed {
    $path = $this->locator
        ->locate($resource);
    $this->container
        ->fileExists($path);
    // first pass to catch parsing errors
    $result = parse_ini_file($path, true);
    if (false === $result || [] === $result) {
        throw new InvalidArgumentException(\sprintf('The "%s" file is not valid.', $resource));
    }
    // real raw parsing
    $result = parse_ini_file($path, true, \INI_SCANNER_RAW);
    if (isset($result['parameters']) && \is_array($result['parameters'])) {
        foreach ($result['parameters'] as $key => $value) {
            if (\is_array($value)) {
                $this->container
                    ->setParameter($key, array_map($this->phpize(...), $value));
            }
            else {
                $this->container
                    ->setParameter($key, $this->phpize($value));
            }
        }
    }
    if ($this->env && \is_array($result['parameters@' . $this->env] ?? null)) {
        foreach ($result['parameters@' . $this->env] as $key => $value) {
            $this->container
                ->setParameter($key, $this->phpize($value));
        }
    }
    return null;
}

API Navigation

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