[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\DependencyInjection\Compiler; 13 14 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; 15 16 /** 17 * This is a directed graph of your services. 18 * 19 * This information can be used by your compiler passes instead of collecting 20 * it themselves which improves performance quite a lot. 21 * 22 * @author Johannes M. Schmitt <schmittjoh@gmail.com> 23 */ 24 class ServiceReferenceGraph 25 { 26 /** 27 * @var ServiceReferenceGraphNode[] 28 */ 29 private $nodes; 30 31 public function __construct() 32 { 33 $this->nodes = array(); 34 } 35 36 /** 37 * Checks if the graph has a specific node. 38 * 39 * @param string $id Id to check 40 * 41 * @return bool 42 */ 43 public function hasNode($id) 44 { 45 return isset($this->nodes[$id]); 46 } 47 48 /** 49 * Gets a node by identifier. 50 * 51 * @param string $id The id to retrieve 52 * 53 * @return ServiceReferenceGraphNode The node matching the supplied identifier 54 * 55 * @throws InvalidArgumentException if no node matches the supplied identifier 56 */ 57 public function getNode($id) 58 { 59 if (!isset($this->nodes[$id])) { 60 throw new InvalidArgumentException(sprintf('There is no node with id "%s".', $id)); 61 } 62 63 return $this->nodes[$id]; 64 } 65 66 /** 67 * Returns all nodes. 68 * 69 * @return ServiceReferenceGraphNode[] An array of all ServiceReferenceGraphNode objects 70 */ 71 public function getNodes() 72 { 73 return $this->nodes; 74 } 75 76 /** 77 * Clears all nodes. 78 */ 79 public function clear() 80 { 81 $this->nodes = array(); 82 } 83 84 /** 85 * Connects 2 nodes together in the Graph. 86 * 87 * @param string $sourceId 88 * @param string $sourceValue 89 * @param string $destId 90 * @param string $destValue 91 * @param string $reference 92 */ 93 public function connect($sourceId, $sourceValue, $destId, $destValue = null, $reference = null) 94 { 95 $sourceNode = $this->createNode($sourceId, $sourceValue); 96 $destNode = $this->createNode($destId, $destValue); 97 $edge = new ServiceReferenceGraphEdge($sourceNode, $destNode, $reference); 98 99 $sourceNode->addOutEdge($edge); 100 $destNode->addInEdge($edge); 101 } 102 103 /** 104 * Creates a graph node. 105 * 106 * @param string $id 107 * @param string $value 108 * 109 * @return ServiceReferenceGraphNode 110 */ 111 private function createNode($id, $value) 112 { 113 if (isset($this->nodes[$id]) && $this->nodes[$id]->getValue() === $value) { 114 return $this->nodes[$id]; 115 } 116 117 return $this->nodes[$id] = new ServiceReferenceGraphNode($id, $value); 118 } 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |