Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

ServiceReferenceGraph.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.18 KiB


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Symfony\Component\DependencyInjection\Compiler;
013   
014  use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
015   
016  /**
017   * This is a directed graph of your services.
018   *
019   * This information can be used by your compiler passes instead of collecting
020   * it themselves which improves performance quite a lot.
021   *
022   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
023   *
024   * @final since version 3.4
025   */
026  class ServiceReferenceGraph
027  {
028      /**
029       * @var ServiceReferenceGraphNode[]
030       */
031      private $nodes = [];
032   
033      /**
034       * Checks if the graph has a specific node.
035       *
036       * @param string $id Id to check
037       *
038       * @return bool
039       */
040      public function hasNode($id)
041      {
042          return isset($this->nodes[$id]);
043      }
044   
045      /**
046       * Gets a node by identifier.
047       *
048       * @param string $id The id to retrieve
049       *
050       * @return ServiceReferenceGraphNode
051       *
052       * @throws InvalidArgumentException if no node matches the supplied identifier
053       */
054      public function getNode($id)
055      {
056          if (!isset($this->nodes[$id])) {
057              throw new InvalidArgumentException(sprintf('There is no node with id "%s".', $id));
058          }
059   
060          return $this->nodes[$id];
061      }
062   
063      /**
064       * Returns all nodes.
065       *
066       * @return ServiceReferenceGraphNode[]
067       */
068      public function getNodes()
069      {
070          return $this->nodes;
071      }
072   
073      /**
074       * Clears all nodes.
075       */
076      public function clear()
077      {
078          foreach ($this->nodes as $node) {
079              $node->clear();
080          }
081          $this->nodes = [];
082      }
083   
084      /**
085       * Connects 2 nodes together in the Graph.
086       *
087       * @param string $sourceId
088       * @param mixed  $sourceValue
089       * @param string $destId
090       * @param mixed  $destValue
091       * @param string $reference
092       */
093      public function connect($sourceId, $sourceValue, $destId, $destValue = null, $reference = null/*, bool $lazy = false, bool $weak = false, bool $byConstructor = false*/)
094      {
095          $lazy = \func_num_args() >= 6 ? func_get_arg(5) : false;
096          $weak = \func_num_args() >= 7 ? func_get_arg(6) : false;
097          $byConstructor = \func_num_args() >= 8 ? func_get_arg(7) : false;
098   
099          if (null === $sourceId || null === $destId) {
100              return;
101          }
102   
103          $sourceNode = $this->createNode($sourceId, $sourceValue);
104          $destNode = $this->createNode($destId, $destValue);
105          $edge = new ServiceReferenceGraphEdge($sourceNode, $destNode, $reference, $lazy, $weak, $byConstructor);
106   
107          $sourceNode->addOutEdge($edge);
108          $destNode->addInEdge($edge);
109      }
110   
111      /**
112       * Creates a graph node.
113       *
114       * @param string $id
115       * @param mixed  $value
116       *
117       * @return ServiceReferenceGraphNode
118       */
119      private function createNode($id, $value)
120      {
121          if (isset($this->nodes[$id]) && $this->nodes[$id]->getValue() === $value) {
122              return $this->nodes[$id];
123          }
124   
125          return $this->nodes[$id] = new ServiceReferenceGraphNode($id, $value);
126      }
127  }
128