|
15 | 15 | use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
16 | 16 | use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
17 | 17 | use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
|
| 18 | +use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass; |
18 | 19 | use Symfony\Component\DependencyInjection\Container;
|
19 | 20 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
20 | 21 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
@@ -140,29 +141,19 @@ public function dump(array $options = array())
|
140 | 141 | $this->initializeMethodNamesMap('Container' === $baseClass ? Container::class : $baseClass);
|
141 | 142 |
|
142 | 143 | if ($this->getProxyDumper() instanceof NullDumper) {
|
143 |
| - (new AnalyzeServiceReferencesPass(true))->process($this->container); |
144 |
| - $this->circularReferences = array(); |
145 |
| - $checkedNodes = array(); |
146 |
| - foreach ($this->container->getCompiler()->getServiceReferenceGraph()->getNodes() as $id => $node) { |
147 |
| - $currentPath = array($id => $id); |
148 |
| - $this->analyzeCircularReferences($node->getOutEdges(), $checkedNodes, $currentPath); |
149 |
| - } |
150 |
| - foreach ($this->circularReferences as $parent => $ids) { |
151 |
| - $path = array($parent); |
152 |
| - while (!isset($ids[$parent])) { |
153 |
| - foreach ($ids as $id) { |
154 |
| - $path[] = $id; |
155 |
| - $ids = $this->circularReferences[$id]; |
156 |
| - break; |
157 |
| - } |
158 |
| - } |
159 |
| - $path[] = $parent.'". Try running "composer require symfony/proxy-manager-bridge'; |
| 144 | + (new AnalyzeServiceReferencesPass(true, false))->process($this->container); |
| 145 | + try { |
| 146 | + (new CheckCircularReferencesPass())->process($this->container); |
| 147 | + } catch (ServiceCircularReferenceException $e) { |
| 148 | + $path = $e->getPath(); |
| 149 | + end($path); |
| 150 | + $path[key($path)] .= '". Try running "composer require symfony/proxy-manager-bridge'; |
160 | 151 |
|
161 |
| - throw new ServiceCircularReferenceException($parent, $path); |
| 152 | + throw new ServiceCircularReferenceException($e->getServiceId(), $path); |
162 | 153 | }
|
163 | 154 | }
|
164 | 155 |
|
165 |
| - (new AnalyzeServiceReferencesPass())->process($this->container); |
| 156 | + (new AnalyzeServiceReferencesPass(false, !$this->getProxyDumper() instanceof NullDumper))->process($this->container); |
166 | 157 | $this->circularReferences = array();
|
167 | 158 | $checkedNodes = array();
|
168 | 159 | foreach ($this->container->getCompiler()->getServiceReferenceGraph()->getNodes() as $id => $node) {
|
@@ -369,7 +360,7 @@ private function analyzeCircularReferences(array $edges, &$checkedNodes, &$curre
|
369 | 360 | $node = $edge->getDestNode();
|
370 | 361 | $id = $node->getId();
|
371 | 362 |
|
372 |
| - if ($node->getValue() && (($edge->isLazy() && !$this->getProxyDumper() instanceof NullDumper) || $edge->isWeak())) { |
| 363 | + if ($node->getValue() && ($edge->isLazy() || $edge->isWeak())) { |
373 | 364 | // no-op
|
374 | 365 | } elseif (isset($currentPath[$id])) {
|
375 | 366 | foreach (array_reverse($currentPath) as $parentId) {
|
|
0 commit comments