This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php
Fabien Potencier b91f082be5 Revert "moved Resource to the Config component"
This reverts commit f53080860a.

Revert "[Router] config fixes"

This reverts commit 51beecc6f2.

Revert "moved duplicated files to a new Config component"

This reverts commit a8ec9b27f0.
2011-02-10 16:14:12 +01:00

65 lines
1.6 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* FileLoader is the abstract class used by all built-in loaders that are file based.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
abstract class FileLoader extends Loader
{
protected $locator;
protected $currentDir;
/**
* Constructor.
*
* @param ContainerBuilder $container A ContainerBuilder instance
*/
public function __construct(ContainerBuilder $container, FileLocator $locator)
{
$this->locator = $locator;
parent::__construct($container);
}
public function getLocator()
{
return $this->locator;
}
/**
* Adds definitions and parameters from a resource.
*
* @param mixed $resource A Resource
*/
public function import($resource, $ignoreErrors = false)
{
try {
$loader = $this->resolve($resource);
if ($loader instanceof FileLoader && null !== $this->currentDir) {
$resource = $this->locator->getAbsolutePath($resource, $this->currentDir);
}
$loader->load($resource);
} catch (\Exception $e) {
if (!$ignoreErrors) {
throw $e;
}
}
}
}