/** * Perform the visit. * * @param ezcWorkflowVisitable $visitable */ protected function doVisit(ezcWorkflowVisitable $visitable) { if ($visitable instanceof ezcWorkflow) { $visitable->startNode->setId(++$this->nextId); $this->startNode = $visitable->startNode; $visitable->endNode->setId(++$this->nextId); $this->endNode = $visitable->endNode; if (count($visitable->finallyNode->getOutNodes()) > 0) { $this->finallyNode = $visitable->finallyNode; $visitable->finallyNode->setId(++$this->nextId); } } else { if ($visitable instanceof ezcWorkflowNode) { if ($visitable !== $this->startNode && $visitable !== $this->endNode && $visitable !== $this->finallyNode) { $id = ++$this->nextId; $visitable->setId($id); } else { $id = $visitable->getId(); } $this->nodes[$id] = $visitable; } } }
/** * Visits the node, adds it to the list of nodes. * * Returns true if the node was added. False if it was already in the list * of nodes. * * @param ezcWorkflowVisitable $visitable * @return boolean */ public function visit(ezcWorkflowVisitable $visitable) { if ($visitable instanceof ezcWorkflow) { $visitor = new ezcWorkflowVisitorMaxNodeIdFinder($visitable); $this->nextId = $visitor->getMaxNodeId() + 1; unset($visitor); if ($visitable->startNode->getId() === false) { $visitable->startNode->setId($this->nextId++); } if ($visitable->endNode->getId() === false) { $visitable->endNode->setId($this->nextId++); } if (count($visitable->finallyNode->getOutNodes()) > 0) { $this->finallyNode = $visitable->finallyNode; if ($visitable->finallyNode->getId() === false) { $visitable->finallyNode->setId($this->nextId++); } } } else { if ($visitable instanceof ezcWorkflowNode) { $id = $visitable->getId(); if ($id === false) { $id = $this->nextId++; $visitable->setId($id); } if (isset($this->nodes[$id])) { return false; } $this->nodes[$id] = $visitable; } } return true; }