Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\DependencyInjection\Compiler; Chris@0: Chris@0: use Symfony\Component\DependencyInjection\Definition; Chris@0: use Symfony\Component\DependencyInjection\Alias; Chris@0: Chris@0: /** Chris@0: * Represents a node in your service graph. Chris@0: * Chris@0: * Value is typically a definition, or an alias. Chris@0: * Chris@0: * @author Johannes M. Schmitt Chris@0: */ Chris@0: class ServiceReferenceGraphNode Chris@0: { Chris@0: private $id; Chris@0: private $inEdges = array(); Chris@0: private $outEdges = array(); Chris@0: private $value; Chris@0: Chris@0: /** Chris@0: * @param string $id The node identifier Chris@0: * @param mixed $value The node value Chris@0: */ Chris@0: public function __construct($id, $value) Chris@0: { Chris@0: $this->id = $id; Chris@0: $this->value = $value; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Adds an in edge to this node. Chris@0: * Chris@0: * @param ServiceReferenceGraphEdge $edge Chris@0: */ Chris@0: public function addInEdge(ServiceReferenceGraphEdge $edge) Chris@0: { Chris@0: $this->inEdges[] = $edge; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Adds an out edge to this node. Chris@0: * Chris@0: * @param ServiceReferenceGraphEdge $edge Chris@0: */ Chris@0: public function addOutEdge(ServiceReferenceGraphEdge $edge) Chris@0: { Chris@0: $this->outEdges[] = $edge; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Checks if the value of this node is an Alias. Chris@0: * Chris@0: * @return bool True if the value is an Alias instance Chris@0: */ Chris@0: public function isAlias() Chris@0: { Chris@0: return $this->value instanceof Alias; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Checks if the value of this node is a Definition. Chris@0: * Chris@0: * @return bool True if the value is a Definition instance Chris@0: */ Chris@0: public function isDefinition() Chris@0: { Chris@0: return $this->value instanceof Definition; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the identifier. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getId() Chris@0: { Chris@0: return $this->id; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the in edges. Chris@0: * Chris@0: * @return array The in ServiceReferenceGraphEdge array Chris@0: */ Chris@0: public function getInEdges() Chris@0: { Chris@0: return $this->inEdges; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the out edges. Chris@0: * Chris@0: * @return array The out ServiceReferenceGraphEdge array Chris@0: */ Chris@0: public function getOutEdges() Chris@0: { Chris@0: return $this->outEdges; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the value of this Node. Chris@0: * Chris@0: * @return mixed The value Chris@0: */ Chris@0: public function getValue() Chris@0: { Chris@0: return $this->value; Chris@0: } Chris@0: }