Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
10 */ | 10 */ |
11 | 11 |
12 namespace Symfony\Component\DependencyInjection\Compiler; | 12 namespace Symfony\Component\DependencyInjection\Compiler; |
13 | 13 |
14 use Symfony\Component\DependencyInjection\Definition; | 14 use Symfony\Component\DependencyInjection\Definition; |
15 use Symfony\Component\DependencyInjection\ExpressionLanguage; | |
15 use Symfony\Component\DependencyInjection\Reference; | 16 use Symfony\Component\DependencyInjection\Reference; |
16 use Symfony\Component\DependencyInjection\ContainerBuilder; | 17 use Symfony\Component\DependencyInjection\ContainerBuilder; |
18 use Symfony\Component\ExpressionLanguage\Expression; | |
17 | 19 |
18 /** | 20 /** |
19 * Run this pass before passes that need to know more about the relation of | 21 * Run this pass before passes that need to know more about the relation of |
20 * your services. | 22 * your services. |
21 * | 23 * |
30 private $container; | 32 private $container; |
31 private $currentId; | 33 private $currentId; |
32 private $currentDefinition; | 34 private $currentDefinition; |
33 private $repeatedPass; | 35 private $repeatedPass; |
34 private $onlyConstructorArguments; | 36 private $onlyConstructorArguments; |
37 private $expressionLanguage; | |
35 | 38 |
36 /** | 39 /** |
37 * @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls | 40 * @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls |
38 */ | 41 */ |
39 public function __construct($onlyConstructorArguments = false) | 42 public function __construct($onlyConstructorArguments = false) |
95 private function processArguments(array $arguments) | 98 private function processArguments(array $arguments) |
96 { | 99 { |
97 foreach ($arguments as $argument) { | 100 foreach ($arguments as $argument) { |
98 if (is_array($argument)) { | 101 if (is_array($argument)) { |
99 $this->processArguments($argument); | 102 $this->processArguments($argument); |
103 } elseif ($argument instanceof Expression) { | |
104 $this->getExpressionLanguage()->compile((string) $argument, array('this' => 'container')); | |
100 } elseif ($argument instanceof Reference) { | 105 } elseif ($argument instanceof Reference) { |
101 $this->graph->connect( | 106 $this->graph->connect( |
102 $this->currentId, | 107 $this->currentId, |
103 $this->currentDefinition, | 108 $this->currentDefinition, |
104 $this->getDefinitionId((string) $argument), | 109 $this->getDefinitionId((string) $argument), |
141 return; | 146 return; |
142 } | 147 } |
143 | 148 |
144 return $id; | 149 return $id; |
145 } | 150 } |
151 | |
152 private function getExpressionLanguage() | |
153 { | |
154 if (null === $this->expressionLanguage) { | |
155 $providers = $this->container->getExpressionLanguageProviders(); | |
156 $this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) { | |
157 if ('""' === substr_replace($arg, '', 1, -1)) { | |
158 $id = stripcslashes(substr($arg, 1, -1)); | |
159 | |
160 $this->graph->connect( | |
161 $this->currentId, | |
162 $this->currentDefinition, | |
163 $this->getDefinitionId($id), | |
164 $this->getDefinition($id) | |
165 ); | |
166 } | |
167 | |
168 return sprintf('$this->get(%s)', $arg); | |
169 }); | |
170 } | |
171 | |
172 return $this->expressionLanguage; | |
173 } | |
146 } | 174 } |