Drupal investigation

ServiceReferenceGraphNode.php 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Compiler;
  11. use Symfony\Component\DependencyInjection\Definition;
  12. use Symfony\Component\DependencyInjection\Alias;
  13. /**
  14. * Represents a node in your service graph.
  15. *
  16. * Value is typically a definition, or an alias.
  17. *
  18. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  19. */
  20. class ServiceReferenceGraphNode
  21. {
  22. private $id;
  23. private $inEdges = array();
  24. private $outEdges = array();
  25. private $value;
  26. /**
  27. * @param string $id The node identifier
  28. * @param mixed $value The node value
  29. */
  30. public function __construct($id, $value)
  31. {
  32. $this->id = $id;
  33. $this->value = $value;
  34. }
  35. /**
  36. * Adds an in edge to this node.
  37. *
  38. * @param ServiceReferenceGraphEdge $edge
  39. */
  40. public function addInEdge(ServiceReferenceGraphEdge $edge)
  41. {
  42. $this->inEdges[] = $edge;
  43. }
  44. /**
  45. * Adds an out edge to this node.
  46. *
  47. * @param ServiceReferenceGraphEdge $edge
  48. */
  49. public function addOutEdge(ServiceReferenceGraphEdge $edge)
  50. {
  51. $this->outEdges[] = $edge;
  52. }
  53. /**
  54. * Checks if the value of this node is an Alias.
  55. *
  56. * @return bool True if the value is an Alias instance
  57. */
  58. public function isAlias()
  59. {
  60. return $this->value instanceof Alias;
  61. }
  62. /**
  63. * Checks if the value of this node is a Definition.
  64. *
  65. * @return bool True if the value is a Definition instance
  66. */
  67. public function isDefinition()
  68. {
  69. return $this->value instanceof Definition;
  70. }
  71. /**
  72. * Returns the identifier.
  73. *
  74. * @return string
  75. */
  76. public function getId()
  77. {
  78. return $this->id;
  79. }
  80. /**
  81. * Returns the in edges.
  82. *
  83. * @return array The in ServiceReferenceGraphEdge array
  84. */
  85. public function getInEdges()
  86. {
  87. return $this->inEdges;
  88. }
  89. /**
  90. * Returns the out edges.
  91. *
  92. * @return array The out ServiceReferenceGraphEdge array
  93. */
  94. public function getOutEdges()
  95. {
  96. return $this->outEdges;
  97. }
  98. /**
  99. * Returns the value of this Node.
  100. *
  101. * @return mixed The value
  102. */
  103. public function getValue()
  104. {
  105. return $this->value;
  106. }
  107. }