Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
ResolveParameterPlaceHoldersPass.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\DependencyInjection\Compiler;
13
14 use Symfony\Component\DependencyInjection\ContainerBuilder;
15 use Symfony\Component\DependencyInjection\Definition;
16 use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
17
18 /**
19 * Resolves all parameter placeholders "%somevalue%" to their real values.
20 *
21 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
22 */
23 class ResolveParameterPlaceHoldersPass extends AbstractRecursivePass
24 {
25 private $bag;
26 private $resolveArrays;
27 private $throwOnResolveException;
28
29 public function __construct($resolveArrays = true, $throwOnResolveException = true)
30 {
31 $this->resolveArrays = $resolveArrays;
32 $this->throwOnResolveException = $throwOnResolveException;
33 }
34
35 /**
36 * {@inheritdoc}
37 *
38 * @throws ParameterNotFoundException
39 */
40 public function process(ContainerBuilder $container)
41 {
42 $this->bag = $container->getParameterBag();
43
44 try {
45 parent::process($container);
46
47 $aliases = [];
48 foreach ($container->getAliases() as $name => $target) {
49 $this->currentId = $name;
50 $aliases[$this->bag->resolveValue($name)] = $target;
51 }
52 $container->setAliases($aliases);
53 } catch (ParameterNotFoundException $e) {
54 $e->setSourceId($this->currentId);
55
56 throw $e;
57 }
58
59 $this->bag->resolve();
60 $this->bag = null;
61 }
62
63 protected function processValue($value, $isRoot = false)
64 {
65 if (\is_string($value)) {
66 try {
67 $v = $this->bag->resolveValue($value);
68 } catch (ParameterNotFoundException $e) {
69 if ($this->throwOnResolveException) {
70 throw $e;
71 }
72
73 $v = null;
74 $this->container->getDefinition($this->currentId)->addError($e->getMessage());
75 }
76
77 return $this->resolveArrays || !$v || !\is_array($v) ? $v : $value;
78 }
79 if ($value instanceof Definition) {
80 $value->setBindings($this->processValue($value->getBindings()));
81 $changes = $value->getChanges();
82 if (isset($changes['class'])) {
83 $value->setClass($this->bag->resolveValue($value->getClass()));
84 }
85 if (isset($changes['file'])) {
86 $value->setFile($this->bag->resolveValue($value->getFile()));
87 }
88 }
89
90 $value = parent::processValue($value, $isRoot);
91
92 if ($value && \is_array($value)) {
93 $value = array_combine($this->bag->resolveValue(array_keys($value)), $value);
94 }
95
96 return $value;
97 }
98 }
99