Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

CheckCircularReferencesPass.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.36 KiB


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\Exception\ServiceCircularReferenceException;
15  use Symfony\Component\DependencyInjection\ContainerBuilder;
16   
17  /**
18   * Checks your services for circular references
19   *
20   * References from method calls are ignored since we might be able to resolve
21   * these references depending on the order in which services are called.
22   *
23   * Circular reference from method calls will only be detected at run-time.
24   *
25   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
26   */
27  class CheckCircularReferencesPass implements CompilerPassInterface
28  {
29      private $currentId;
30      private $currentPath;
31      private $checkedNodes;
32   
33      /**
34       * Checks the ContainerBuilder object for circular references.
35       *
36       * @param ContainerBuilder $container The ContainerBuilder instances
37       */
38      public function process(ContainerBuilder $container)
39      {
40          $graph = $container->getCompiler()->getServiceReferenceGraph();
41   
42          $this->checkedNodes = array();
43          foreach ($graph->getNodes() as $id => $node) {
44              $this->currentId = $id;
45              $this->currentPath = array($id);
46   
47              $this->checkOutEdges($node->getOutEdges());
48          }
49      }
50   
51      /**
52       * Checks for circular references.
53       *
54       * @param ServiceReferenceGraphEdge[] $edges An array of Edges
55       *
56       * @throws ServiceCircularReferenceException When a circular reference is found.
57       */
58      private function checkOutEdges(array $edges)
59      {
60          foreach ($edges as $edge) {
61              $node      = $edge->getDestNode();
62              $id        = $node->getId();
63   
64              if (empty($this->checkedNodes[$id])) {
65                  $searchKey = array_search($id, $this->currentPath);
66                  $this->currentPath[] = $id;
67   
68                  if (false !== $searchKey) {
69                      throw new ServiceCircularReferenceException($id, array_slice($this->currentPath, $searchKey));
70                  }
71   
72                  $this->checkOutEdges($node->getOutEdges());
73   
74                  $this->checkedNodes[$id] = true;
75                  array_pop($this->currentPath);
76              }
77          }
78      }
79  }
80