[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Loader/ -> IniFileLoader.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\DependencyInjection\Loader;
  13  
  14  use Symfony\Component\Config\Resource\FileResource;
  15  use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  16  
  17  /**
  18   * IniFileLoader loads parameters from INI files.
  19   *
  20   * @author Fabien Potencier <fabien@symfony.com>
  21   */
  22  class IniFileLoader extends FileLoader
  23  {
  24      /**
  25       * {@inheritdoc}
  26       */
  27      public function load($resource, $type = null)
  28      {
  29          $path = $this->locator->locate($resource);
  30  
  31          $this->container->addResource(new FileResource($path));
  32  
  33          $result = parse_ini_file($path, true);
  34          if (false === $result || array() === $result) {
  35              throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $resource));
  36          }
  37  
  38          if (isset($result['parameters']) && \is_array($result['parameters'])) {
  39              foreach ($result['parameters'] as $key => $value) {
  40                  $this->container->setParameter($key, $value);
  41              }
  42          }
  43      }
  44  
  45      /**
  46       * {@inheritdoc}
  47       */
  48      public function supports($resource, $type = null)
  49      {
  50          return \is_string($resource) && 'ini' === pathinfo($resource, PATHINFO_EXTENSION);
  51      }
  52  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1