4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Loader;
14 use Symfony\Component\Config\Resource\FileResource;
15 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
18 * IniFileLoader loads parameters from INI files.
20 * @author Fabien Potencier <fabien@symfony.com>
22 class IniFileLoader extends FileLoader
27 public function load($resource, $type = null)
29 $path = $this->locator->locate($resource);
31 $this->container->addResource(new FileResource($path));
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));
38 if (isset($result['parameters']) && is_array($result['parameters'])) {
39 foreach ($result['parameters'] as $key => $value) {
40 $this->container->setParameter($key, $value);
48 public function supports($resource, $type = null)
50 return is_string($resource) && 'ini' === pathinfo($resource, PATHINFO_EXTENSION);