Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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: 09.10.2024, 12:56 - Dateigröße: 2.79 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  class ServiceReferenceGraph
 025  {
 026      /**
 027       * @var ServiceReferenceGraphNode[]
 028       */
 029      private $nodes = array();
 030   
 031      /**
 032       * Checks if the graph has a specific node.
 033       *
 034       * @param string $id Id to check
 035       *
 036       * @return bool
 037       */
 038      public function hasNode($id)
 039      {
 040          return isset($this->nodes[$id]);
 041      }
 042   
 043      /**
 044       * Gets a node by identifier.
 045       *
 046       * @param string $id The id to retrieve
 047       *
 048       * @return ServiceReferenceGraphNode The node matching the supplied identifier
 049       *
 050       * @throws InvalidArgumentException if no node matches the supplied identifier
 051       */
 052      public function getNode($id)
 053      {
 054          if (!isset($this->nodes[$id])) {
 055              throw new InvalidArgumentException(sprintf('There is no node with id "%s".', $id));
 056          }
 057   
 058          return $this->nodes[$id];
 059      }
 060   
 061      /**
 062       * Returns all nodes.
 063       *
 064       * @return ServiceReferenceGraphNode[] An array of all ServiceReferenceGraphNode objects
 065       */
 066      public function getNodes()
 067      {
 068          return $this->nodes;
 069      }
 070   
 071      /**
 072       * Clears all nodes.
 073       */
 074      public function clear()
 075      {
 076          $this->nodes = array();
 077      }
 078   
 079      /**
 080       * Connects 2 nodes together in the Graph.
 081       *
 082       * @param string $sourceId
 083       * @param string $sourceValue
 084       * @param string $destId
 085       * @param string $destValue
 086       * @param string $reference
 087       */
 088      public function connect($sourceId, $sourceValue, $destId, $destValue = null, $reference = null)
 089      {
 090          $sourceNode = $this->createNode($sourceId, $sourceValue);
 091          $destNode = $this->createNode($destId, $destValue);
 092          $edge = new ServiceReferenceGraphEdge($sourceNode, $destNode, $reference);
 093   
 094          $sourceNode->addOutEdge($edge);
 095          $destNode->addInEdge($edge);
 096      }
 097   
 098      /**
 099       * Creates a graph node.
 100       *
 101       * @param string $id
 102       * @param string $value
 103       *
 104       * @return ServiceReferenceGraphNode
 105       */
 106      private function createNode($id, $value)
 107      {
 108          if (isset($this->nodes[$id]) && $this->nodes[$id]->getValue() === $value) {
 109              return $this->nodes[$id];
 110          }
 111   
 112          return $this->nodes[$id] = new ServiceReferenceGraphNode($id, $value);
 113      }
 114  }
 115