You are here

class IniFileLoader in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/translation/Loader/IniFileLoader.php \Symfony\Component\Translation\Loader\IniFileLoader
  2. 8.0 vendor/symfony/dependency-injection/Loader/IniFileLoader.php \Symfony\Component\DependencyInjection\Loader\IniFileLoader
Same name and namespace in other branches
  1. 8 vendor/symfony/dependency-injection/Loader/IniFileLoader.php \Symfony\Component\DependencyInjection\Loader\IniFileLoader

IniFileLoader loads parameters from INI files.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

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

Expanded class hierarchy of IniFileLoader

4 files declare their use of IniFileLoader
IniFileLoaderTest.php in vendor/symfony/dependency-injection/Tests/Loader/IniFileLoaderTest.php
Kernel.php in vendor/symfony/http-kernel/Kernel.php
XmlFileLoaderTest.php in vendor/symfony/dependency-injection/Tests/Loader/XmlFileLoaderTest.php
YamlFileLoaderTest.php in vendor/symfony/dependency-injection/Tests/Loader/YamlFileLoaderTest.php
2 string references to 'IniFileLoader'
services4.yml in vendor/symfony/dependency-injection/Tests/Fixtures/yaml/services4.yml
vendor/symfony/dependency-injection/Tests/Fixtures/yaml/services4.yml
TranslatorTest::getTransFileTests in vendor/symfony/translation/Tests/TranslatorTest.php

File

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

Namespace

Symfony\Component\DependencyInjection\Loader
View source
class IniFileLoader extends FileLoader {

  /**
   * {@inheritdoc}
   */
  public function load($resource, $type = null) {
    $path = $this->locator
      ->locate($resource);
    $this->container
      ->addResource(new FileResource($path));
    $result = parse_ini_file($path, true);
    if (false === $result || array() === $result) {
      throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $resource));
    }
    if (isset($result['parameters']) && is_array($result['parameters'])) {
      foreach ($result['parameters'] as $key => $value) {
        $this->container
          ->setParameter($key, $value);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function supports($resource, $type = null) {
    return is_string($resource) && 'ini' === pathinfo($resource, PATHINFO_EXTENSION);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileLoader::$container protected property
FileLoader::__construct public function Constructor.
IniFileLoader::load public function
IniFileLoader::supports public function