class 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 drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php
Kernel.php in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php
XmlFileLoaderTest.php in drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
YamlFileLoaderTest.php in drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
1 string reference to 'IniFileLoader'
services4.yml in drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml
drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php, line 22

Namespace

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

  /**
   * Loads a resource.
   *
   * @param mixed  $file The resource
   * @param string $type The resource type
   *
   * @throws InvalidArgumentException When ini file is not valid
   */
  public function load($file, $type = null) {
    $path = $this->locator
      ->locate($file);
    $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.', $file));
    }
    if (isset($result['parameters']) && is_array($result['parameters'])) {
      foreach ($result['parameters'] as $key => $value) {
        $this->container
          ->setParameter($key, $value);
      }
    }
  }

  /**
   * Returns true if this class supports the given resource.
   *
   * @param mixed  $resource A resource
   * @param string $type     The resource type
   *
   * @return Boolean true if this class supports the given resource, false otherwise
   */
  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 Loads a resource.
IniFileLoader::supports public function Returns true if this class supports the given resource.