public function testXmlSerializationRoundtrip() { $node = new ymcPipeBasicNodeMock($this->getMock('ymcPipe')); $node->config->setPropertiesTestHelper(array('hi' => 'du')); $document = new DOMDocument(); $element = $document->createElement('xyzblub'); $document->appendChild($element); $node->serializeToXml($element); $newNode = ymcPipeNode::unserializeFromXml($element, $this->getMock('ymcPipe')); $this->assertEquals($node, $newNode); }
public function execute(ymcPipeExecution $execution) { //echo 'execute Node '.$this->id."\n"; $this->executed = true; return parent::execute($execution); }
public function __construct(ymcPipe $pipe, $input) { $this->input = $input; parent::__construct($pipe); }
/** * Adds a node to the outgoing nodes of this node. * * Automatically adds $node to the workflow and adds * this node as an in node of $node. * * @param ymcPipeNode $node The node that is to be added as outgoing node. * @throws ymcPipeNodeDifferentPipesException if $node is not in the same pipe as $this. * @return ymcPipeNode $this */ public function addOutNode(ymcPipeNode $node) { // Check whether the other node is already an outgoing node of this node. if ($this->outNodes->contains($node) === false) { // Add this node as an incoming node to the other node. if (!self::$internalCall) { // Fail, if $node is not in the same Pipe as $this if (!$this->isNodeFromSamePipe($node)) { throw new ymcPipeNodeDifferentPipesException(); } self::$internalCall = true; $node->addInNode($this); } else { self::$internalCall = false; } // Add the other node as an outgoing node to this node. $this->outNodes[] = $node; } return $this; }
public static function loadFromDocument(DOMDocument $document) { $pipe = new ymcPipe($document->documentElement->getAttribute('name')); // Create node objects. $nodes = array(); $xmlNodes = $document->getElementsByTagName('node'); // unserialize nodes foreach ($xmlNodes as $xmlNode) { $id = (int) $xmlNode->getAttribute('id'); $node = ymcPipeNode::unserializeFromXml($xmlNode, $pipe); $node->id = (int) $id; $nodes[$id] = $node; } // Connect node objects. foreach ($xmlNodes as $xmlNode) { $id = (int) $xmlNode->getAttribute('id'); foreach ($xmlNode->getElementsByTagName('outNode') as $outNode) { $nodes[$id]->addOutNode($nodes[(int) $outNode->getAttribute('id')]); } } //$pipe->definitionStorage = $this; $pipe->version = $document->documentElement->getAttribute('version'); //$pipe->verify(); return $pipe; }