Augmentation vers version 3.3.0
This commit is contained in:
@@ -34,7 +34,7 @@ class DelegatingLoader extends Loader
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
if (false === $loader = $this->resolver->resolve($resource, $type)) {
|
||||
throw new FileLoaderLoadException($resource);
|
||||
throw new FileLoaderLoadException($resource, null, null, null, $type);
|
||||
}
|
||||
|
||||
return $loader->load($resource, $type);
|
||||
|
||||
88
vendor/symfony/config/Loader/FileLoader.php
vendored
88
vendor/symfony/config/Loader/FileLoader.php
vendored
@@ -13,7 +13,10 @@ namespace Symfony\Component\Config\Loader;
|
||||
|
||||
use Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException;
|
||||
use Symfony\Component\Config\Exception\FileLoaderLoadException;
|
||||
use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;
|
||||
use Symfony\Component\Config\FileLocatorInterface;
|
||||
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.
|
||||
@@ -22,7 +25,7 @@ use Symfony\Component\Config\FileLocatorInterface;
|
||||
*/
|
||||
abstract class FileLoader extends Loader
|
||||
{
|
||||
protected static $loading = array();
|
||||
protected static $loading = [];
|
||||
|
||||
protected $locator;
|
||||
|
||||
@@ -65,26 +68,75 @@ abstract class FileLoader extends Loader
|
||||
*
|
||||
* @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 = [];
|
||||
$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 = [];
|
||||
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) {
|
||||
// we fallback to the current locator to keep BC
|
||||
// as some some loaders do not call the parent __construct()
|
||||
// @deprecated should be removed in 3.0
|
||||
$locator = $loader->getLocator();
|
||||
if (null === $locator) {
|
||||
@trigger_error('Not calling the parent constructor in '.\get_class($loader).' which extends '.__CLASS__.' is deprecated since Symfony 2.7 and will not be supported anymore in 3.0.', E_USER_DEPRECATED);
|
||||
$locator = $this->locator;
|
||||
}
|
||||
|
||||
$resource = $locator->locate($resource, $this->currentDir, false);
|
||||
$resource = $loader->getLocator()->locate($resource, $this->currentDir, false);
|
||||
}
|
||||
|
||||
$resources = \is_array($resource) ? $resource : array($resource);
|
||||
$resources = \is_array($resource) ? $resource : [$resource];
|
||||
for ($i = 0; $i < $resourcesCount = \count($resources); ++$i) {
|
||||
if (isset(self::$loading[$resources[$i]])) {
|
||||
if ($i == $resourcesCount - 1) {
|
||||
@@ -99,16 +151,10 @@ abstract class FileLoader extends Loader
|
||||
|
||||
try {
|
||||
$ret = $loader->load($resource, $type);
|
||||
} catch (\Exception $e) {
|
||||
} finally {
|
||||
unset(self::$loading[$resource]);
|
||||
throw $e;
|
||||
} catch (\Throwable $e) {
|
||||
unset(self::$loading[$resource]);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
unset(self::$loading[$resource]);
|
||||
|
||||
return $ret;
|
||||
} catch (FileLoaderImportCircularReferenceException $e) {
|
||||
throw $e;
|
||||
@@ -119,8 +165,10 @@ abstract class FileLoader extends Loader
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw new FileLoaderLoadException($resource, $sourceResource, null, $e);
|
||||
throw new FileLoaderLoadException($resource, $sourceResource, null, $e, $type);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
36
vendor/symfony/config/Loader/GlobFileLoader.php
vendored
Normal file
36
vendor/symfony/config/Loader/GlobFileLoader.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* GlobFileLoader loads files from a glob pattern.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class GlobFileLoader extends FileLoader
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
return $this->import($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return 'glob' === $type;
|
||||
}
|
||||
}
|
||||
2
vendor/symfony/config/Loader/Loader.php
vendored
2
vendor/symfony/config/Loader/Loader.php
vendored
@@ -70,7 +70,7 @@ abstract class Loader implements LoaderInterface
|
||||
$loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type);
|
||||
|
||||
if (false === $loader) {
|
||||
throw new FileLoaderLoadException($resource);
|
||||
throw new FileLoaderLoadException($resource, null, null, null, $type);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
||||
@@ -24,12 +24,12 @@ class LoaderResolver implements LoaderResolverInterface
|
||||
/**
|
||||
* @var LoaderInterface[] An array of LoaderInterface objects
|
||||
*/
|
||||
private $loaders = array();
|
||||
private $loaders = [];
|
||||
|
||||
/**
|
||||
* @param LoaderInterface[] $loaders An array of loaders
|
||||
*/
|
||||
public function __construct(array $loaders = array())
|
||||
public function __construct(array $loaders = [])
|
||||
{
|
||||
foreach ($loaders as $loader) {
|
||||
$this->addLoader($loader);
|
||||
|
||||
Reference in New Issue
Block a user