* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Loader; use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Config\Exception\FileLoaderLoadException; use Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; use Symfony\Component\Config\Resource\FileExistenceResource; use Symfony\Component\Config\Resource\GlobResource; /** * FileLoader is the abstract class used by all built-in loaders that are file based. * * @author Fabien Potencier */ abstract class FileLoader extends Loader { protected static $loading = array(); protected $locator; private $currentDir; public function __construct(FileLocatorInterface $locator) { $this->locator = $locator; } /** * Sets the current directory. * * @param string $dir */ public function setCurrentDir($dir) { $this->currentDir = $dir; } /** * Returns the file locator used by this loader. * * @return FileLocatorInterface */ public function getLocator() { return $this->locator; } /** * Imports a resource. * * @param mixed $resource A Resource * @param string|null $type The resource type or null if unknown * @param bool $ignoreErrors Whether to ignore import errors or not * @param string|null $sourceResource The original resource importing the new resource * * @return mixed * * @throws FileLoaderLoadException * @throws FileLoaderImportCircularReferenceException * @throws FileLocatorFileNotFoundException */ public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null) { if (is_string($resource) && strlen($resource) !== $i = strcspn($resource, '*?{[')) { $ret = array(); $isSubpath = 0 !== $i && false !== strpos(substr($resource, 0, $i), '/'); foreach ($this->glob($resource, false, $_, $ignoreErrors || !$isSubpath) as $path => $info) { if (null !== $res = $this->doImport($path, $type, $ignoreErrors, $sourceResource)) { $ret[] = $res; } $isSubpath = true; } if ($isSubpath) { return isset($ret[1]) ? $ret : (isset($ret[0]) ? $ret[0] : null); } } return $this->doImport($resource, $type, $ignoreErrors, $sourceResource); } /** * @internal */ protected function glob($pattern, $recursive, &$resource = null, $ignoreErrors = false) { if (strlen($pattern) === $i = strcspn($pattern, '*?{[')) { $prefix = $pattern; $pattern = ''; } elseif (0 === $i || false === strpos(substr($pattern, 0, $i), '/')) { $prefix = '.'; $pattern = '/'.$pattern; } else { $prefix = dirname(substr($pattern, 0, 1 + $i)); $pattern = substr($pattern, strlen($prefix)); } try { $prefix = $this->locator->locate($prefix, $this->currentDir, true); } catch (FileLocatorFileNotFoundException $e) { if (!$ignoreErrors) { throw $e; } $resource = array(); foreach ($e->getPaths() as $path) { $resource[] = new FileExistenceResource($path); } return; } $resource = new GlobResource($prefix, $pattern, $recursive); foreach ($resource as $path => $info) { yield $path => $info; } } private function doImport($resource, $type = null, $ignoreErrors = false, $sourceResource = null) { try { $loader = $this->resolve($resource, $type); if ($loader instanceof self && null !== $this->currentDir) { $resource = $loader->getLocator()->locate($resource, $this->currentDir, false); } $resources = is_array($resource) ? $resource : array($resource); for ($i = 0; $i < $resourcesCount = count($resources); ++$i) { if (isset(self::$loading[$resources[$i]])) { if ($i == $resourcesCount - 1) { throw new FileLoaderImportCircularReferenceException(array_keys(self::$loading)); } } else { $resource = $resources[$i]; break; } } self::$loading[$resource] = true; try { $ret = $loader->load($resource, $type); } finally { unset(self::$loading[$resource]); } return $ret; } catch (FileLoaderImportCircularReferenceException $e) { throw $e; } catch (\Exception $e) { if (!$ignoreErrors) { // prevent embedded imports from nesting multiple exceptions if ($e instanceof FileLoaderLoadException) { throw $e; } throw new FileLoaderLoadException($resource, $sourceResource, null, $e, $type); } } } } __halt_compiler();----SIGNATURE:----RQusUcta9z6uO7A07eBpAzYM+NB9U8T4yMU2JFy67jVwx4iuQB49xW5k+PtV8LKuP8XSIKF3BFBiF+FTUKObBi1M0by0NzTesXP8S5qdeNLbItw+3YfMpGDSk4hUQvETlMv1kgixoq5+0EmM1WO1pJsl+R+AWj3OQwf+9HxaOFWDWcEzICHxy3bvP1Nhd+QdzlfwG8Jx2mSyREcWNHZhDP2RLB8gP9GO1pQm58YhDUJ1b8R4cZOYk7VT1q4ZHetyM8O5aUYMbob4wsXSZjMVvdfmPKxQOKNEoy+EMVHWASrnSFiWF0K6wh3wkVzS6MYrX5DVxBxKNBiI9nzT3pTp8TDTslXUrfCBka5e0c/Ml0uOohXSQn9OSOec3GFSx4iaGN6lK/PJLXgRVF5XnFZSWn0aohYdFfJAdkqC67CVs3vDvnDyI/2GvB8sZMa08wCXu+CBPpP6Rb0qJjBUXdcrbZpWoUWFfkpAU3HJtkDtMuNY5iNwNgRqRq5kqKHnxwwhGnBr9TT1UyyxTXA/d+1iZk8fWNkySAyzkxX9qN9pt4sw022qTqrA4w0LjIs2p62W8JVn4Xb+rthX5lsW/nVgN+ECcf3ru83DIeUPMCisM9VGM23htNsmE39Sj7W2YIWt873WK7myxsPtMGnwMZmNQDFmLOc1eJz+gI6P3fXMXDI=----ATTACHMENT:----NjE2NTkwNjM1MjA0MjY0OSA2NDQ5MTYzNTI5NzU1NjQ5IDU5NzU2MzQ4Mzg5MTU1MjM=