accept( $this ); } /** * 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 ) { $visitable->startNode->setId( $this->nextId++ ); $visitable->endNode->setId( $this->nextId++ ); if ( count( $visitable->finallyNode->getOutNodes() ) > 0 ) { $visitable->finallyNode->setId( $this->nextId++ ); $this->finallyNode = $visitable->finallyNode; } } 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; } /** * Returns the collected nodes. * * @return array */ public function getNodes() { if ( $this->finallyNode !== null && !$this->finallyNodeVisited ) { $this->finallyNode->accept( $this ); $this->finallyNode = true; } if ( !$this->sorted ) { ksort( $this->nodes ); $this->sorted = true; } return $this->nodes; } } ?>