Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/ResolveParameterPlaceHoldersPass.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
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\DependencyInjection\Compiler; | |
13 | |
14 use Symfony\Component\DependencyInjection\ContainerBuilder; | |
15 use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; | |
16 | |
17 /** | |
18 * Resolves all parameter placeholders "%somevalue%" to their real values. | |
19 * | |
20 * @author Johannes M. Schmitt <schmittjoh@gmail.com> | |
21 */ | |
22 class ResolveParameterPlaceHoldersPass implements CompilerPassInterface | |
23 { | |
24 /** | |
25 * Processes the ContainerBuilder to resolve parameter placeholders. | |
26 * | |
27 * @param ContainerBuilder $container | |
28 * | |
29 * @throws ParameterNotFoundException | |
30 */ | |
31 public function process(ContainerBuilder $container) | |
32 { | |
33 $parameterBag = $container->getParameterBag(); | |
34 | |
35 foreach ($container->getDefinitions() as $id => $definition) { | |
36 try { | |
37 $definition->setClass($parameterBag->resolveValue($definition->getClass())); | |
38 $definition->setFile($parameterBag->resolveValue($definition->getFile())); | |
39 $definition->setArguments($parameterBag->resolveValue($definition->getArguments())); | |
40 | |
41 $factory = $definition->getFactory(); | |
42 | |
43 if (is_array($factory) && isset($factory[0])) { | |
44 $factory[0] = $parameterBag->resolveValue($factory[0]); | |
45 $definition->setFactory($factory); | |
46 } | |
47 | |
48 $calls = array(); | |
49 foreach ($definition->getMethodCalls() as $name => $arguments) { | |
50 $calls[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($arguments); | |
51 } | |
52 $definition->setMethodCalls($calls); | |
53 | |
54 $definition->setProperties($parameterBag->resolveValue($definition->getProperties())); | |
55 } catch (ParameterNotFoundException $e) { | |
56 $e->setSourceId($id); | |
57 | |
58 throw $e; | |
59 } | |
60 } | |
61 | |
62 $aliases = array(); | |
63 foreach ($container->getAliases() as $name => $target) { | |
64 $aliases[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($target); | |
65 } | |
66 $container->setAliases($aliases); | |
67 | |
68 $parameterBag->resolve(); | |
69 } | |
70 } |