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