comparison vendor/symfony/dependency-injection/Compiler/CheckCircularReferencesPass.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
29 private $currentPath; 29 private $currentPath;
30 private $checkedNodes; 30 private $checkedNodes;
31 31
32 /** 32 /**
33 * Checks the ContainerBuilder object for circular references. 33 * Checks the ContainerBuilder object for circular references.
34 *
35 * @param ContainerBuilder $container The ContainerBuilder instances
36 */ 34 */
37 public function process(ContainerBuilder $container) 35 public function process(ContainerBuilder $container)
38 { 36 {
39 $graph = $container->getCompiler()->getServiceReferenceGraph(); 37 $graph = $container->getCompiler()->getServiceReferenceGraph();
40 38
49 /** 47 /**
50 * Checks for circular references. 48 * Checks for circular references.
51 * 49 *
52 * @param ServiceReferenceGraphEdge[] $edges An array of Edges 50 * @param ServiceReferenceGraphEdge[] $edges An array of Edges
53 * 51 *
54 * @throws ServiceCircularReferenceException When a circular reference is found. 52 * @throws ServiceCircularReferenceException when a circular reference is found
55 */ 53 */
56 private function checkOutEdges(array $edges) 54 private function checkOutEdges(array $edges)
57 { 55 {
58 foreach ($edges as $edge) { 56 foreach ($edges as $edge) {
59 $node = $edge->getDestNode(); 57 $node = $edge->getDestNode();
60 $id = $node->getId(); 58 $id = $node->getId();
61 59
62 if (empty($this->checkedNodes[$id])) { 60 if (empty($this->checkedNodes[$id])) {
63 // don't check circular dependencies for lazy services 61 // Don't check circular references for lazy edges
64 if (!$node->getValue() || !$node->getValue()->isLazy()) { 62 if (!$node->getValue() || (!$edge->isLazy() && !$edge->isWeak())) {
65 $searchKey = array_search($id, $this->currentPath); 63 $searchKey = array_search($id, $this->currentPath);
66 $this->currentPath[] = $id; 64 $this->currentPath[] = $id;
67 65
68 if (false !== $searchKey) { 66 if (false !== $searchKey) {
69 throw new ServiceCircularReferenceException($id, array_slice($this->currentPath, $searchKey)); 67 throw new ServiceCircularReferenceException($id, array_slice($this->currentPath, $searchKey));