public function __construct(ProcessModel $model, Node $startNode = NULL, array $variables = []) { $this->model = $model; $this->variables = $variables; if ($startNode === NULL) { $initial = $model->findInitialNodes(); if (count($initial) != 1) { throw new \RuntimeException(sprintf('Process "%s" does not declare exactly 1 start node', $model->getTitle())); } $this->startNode = array_shift($initial); } else { $this->startNode = $startNode; } }
/** * Take a transition from the given node. * * @param string $transition ID of the transition, ommitting it will assume a single outgoing transition. * * @throws \RuntimeException When the execution has been terminated. */ public function take($transition = NULL) { if ($this->isTerminated()) { throw new \RuntimeException(sprintf('Cannot take transition in terminated %s', $this)); } if ($transition !== NULL && !$transition instanceof Transition) { $transition = $this->model->findTransition($transition); } $this->engine->pushCommand($this->engine->createTakeTransitionCommand($this, $transition)); }
protected function findSubProcessStartNode($id, ProcessModel $subModel) { $startNode = NULL; foreach ($subModel->findStartNodes() as $candidate) { $behavior = $candidate->getBehavior(); if ($behavior instanceof StartEventBehaviorInterface) { $startNode = $candidate; break; } } if ($startNode === NULL) { throw new \RuntimeException(sprintf('Missing start node of sub process %s', $id)); } return $startNode; }