[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
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\Config\Loader; 13 14 use Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException; 15 use Symfony\Component\Config\Exception\FileLoaderLoadException; 16 use Symfony\Component\Config\FileLocatorInterface; 17 18 /** 19 * FileLoader is the abstract class used by all built-in loaders that are file based. 20 * 21 * @author Fabien Potencier <fabien@symfony.com> 22 */ 23 abstract class FileLoader extends Loader 24 { 25 protected static $loading = array(); 26 27 protected $locator; 28 29 private $currentDir; 30 31 public function __construct(FileLocatorInterface $locator) 32 { 33 $this->locator = $locator; 34 } 35 36 /** 37 * Sets the current directory. 38 * 39 * @param string $dir 40 */ 41 public function setCurrentDir($dir) 42 { 43 $this->currentDir = $dir; 44 } 45 46 /** 47 * Returns the file locator used by this loader. 48 * 49 * @return FileLocatorInterface 50 */ 51 public function getLocator() 52 { 53 return $this->locator; 54 } 55 56 /** 57 * Imports a resource. 58 * 59 * @param mixed $resource A Resource 60 * @param string|null $type The resource type or null if unknown 61 * @param bool $ignoreErrors Whether to ignore import errors or not 62 * @param string|null $sourceResource The original resource importing the new resource 63 * 64 * @return mixed 65 * 66 * @throws FileLoaderLoadException 67 * @throws FileLoaderImportCircularReferenceException 68 */ 69 public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null) 70 { 71 try { 72 $loader = $this->resolve($resource, $type); 73 74 if ($loader instanceof self && null !== $this->currentDir) { 75 // we fallback to the current locator to keep BC 76 // as some some loaders do not call the parent __construct() 77 // @deprecated should be removed in 3.0 78 $locator = $loader->getLocator(); 79 if (null === $locator) { 80 @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); 81 $locator = $this->locator; 82 } 83 84 $resource = $locator->locate($resource, $this->currentDir, false); 85 } 86 87 $resources = \is_array($resource) ? $resource : array($resource); 88 for ($i = 0; $i < $resourcesCount = \count($resources); ++$i) { 89 if (isset(self::$loading[$resources[$i]])) { 90 if ($i == $resourcesCount - 1) { 91 throw new FileLoaderImportCircularReferenceException(array_keys(self::$loading)); 92 } 93 } else { 94 $resource = $resources[$i]; 95 break; 96 } 97 } 98 self::$loading[$resource] = true; 99 100 try { 101 $ret = $loader->load($resource, $type); 102 } catch (\Exception $e) { 103 unset(self::$loading[$resource]); 104 throw $e; 105 } catch (\Throwable $e) { 106 unset(self::$loading[$resource]); 107 throw $e; 108 } 109 110 unset(self::$loading[$resource]); 111 112 return $ret; 113 } catch (FileLoaderImportCircularReferenceException $e) { 114 throw $e; 115 } catch (\Exception $e) { 116 if (!$ignoreErrors) { 117 // prevent embedded imports from nesting multiple exceptions 118 if ($e instanceof FileLoaderLoadException) { 119 throw $e; 120 } 121 122 throw new FileLoaderLoadException($resource, $sourceResource, null, $e); 123 } 124 } 125 } 126 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |