/** * {@inheritdoc} */ public function enter(VirtualExecution $execution) { $execution->getEngine()->debug('Reached terminate end event "{name}"', ['name' => $this->getStringValue($this->name, $execution->getExpressionContext())]); $engine = $execution->getEngine(); $engine->notify(new ActivityCompletedEvent($execution->getNode()->getId(), $execution, $engine)); $root = $execution->getScopeRoot(); $root->setNode($execution->getNode()); $root->setTransition($execution->getTransition()); $root->terminate(false); }
/** * {@inheritdoc} */ public function createEventSubscriptions(VirtualExecution $execution, $activityId, Node $node = NULL) { $date = $this->getDateValue($this->date, $execution->getExpressionContext()); if (!$date instanceof \DateTimeInterface) { throw new \RuntimeException(sprintf('Expecting DateTimeInterface, given %s', is_object($date) ? get_class($date) : gettype($date))); } $execution->getEngine()->executeCommand(new CreateTimerSubscriptionCommand($date, $execution, $activityId, $node === NULL ? $execution->getNode() : $node)); }
/** * {@inheritdoc} */ public function processSignal(VirtualExecution $execution, $signal, array $variables = [], array $delegation = []) { $engine = $execution->getEngine(); $engine->notify(new ActivityCompletedEvent($execution->getNode()->getId(), $execution, $engine)); $node = $execution->getProcessModel()->findNode($delegation['nodeId']); $engine->notify(new ActivityStartedEvent($node->getId(), $execution, $engine)); $this->delegateSignal($execution, $signal, $variables, $delegation); }
/** * {@inheritdoc} */ public function enter(VirtualExecution $execution) { $engine = $execution->getEngine(); $name = $this->getStringValue($this->name, $execution->getExpressionContext()); $engine->debug('{execution} reached checkpoint "{checkpoint}" ({node})', ['execution' => (string) $execution, 'checkpoint' => $this->name, 'node' => $execution->getNode()->getId()]); $engine->notify(new CheckpointReachedEvent($name, new DelegateExecution($execution), $engine)); $this->leave($execution); }
/** * {@inheritdoc} */ public function enter(VirtualExecution $execution) { $model = $execution->getProcessModel(); $execution->getEngine()->debug('Starting sub process "{process}"', ['process' => $this->getStringValue($this->name, $execution->getExpressionContext())]); $startNode = $model->findNode($this->startNodeId); if (!$startNode->getBehavior() instanceof NoneStartEventBehavior) { throw new \RuntimeException(sprintf('Cannot start sub process %s ("%s") because it is missing start node %s', $execution->getNode()->getId(), $this->getStringValue($this->name, $execution->getExpressionContext()), $this->startNodeId)); } $execution->waitForSignal(); $sub = $execution->createNestedExecution($model, $startNode, true, false); $sub->execute($startNode); }
protected function dumpExecution(VirtualExecution $exec) { $node = $exec->getNode(); $nodeId = $node === NULL ? NULL : $node->getId(); printf("%s%s [ %s ]\n", str_repeat(' ', $exec->getExecutionDepth()), $nodeId, $exec->getId()); foreach ($exec->findChildExecutions() as $child) { $this->dumpExecution($child); } }
/** * {@inheritdoc} */ public function createEventSubscriptions(VirtualExecution $execution, $activityId, Node $node = NULL) { $execution->getEngine()->pushCommand(new CreateSignalSubscriptionCommand($this->signal, $execution, $activityId, $node === NULL ? $execution->getNode() : $node)); parent::createEventSubscriptions($execution, $activityId, $node); }
/** * {@inheritdoc} */ public function createEventSubscriptions(VirtualExecution $execution, $activityId, Node $node = NULL) { $execution->getEngine()->executeCommand(new CreateMessageSubscriptionCommand($this->message, $execution, $activityId, $node === NULL ? $execution->getNode() : $node)); }
/** * Create a new execution concurrent to the given execution and have it take the given transitions. * * If the given execution is concurrent this method will create a new child execution from the parent execution. * Otherwise a new concurrent root will be introduced as parent of the given execution. * * @param VirtualExecution $execution * @param Node $node * @param array $transitions * @return VirtualExecution The new concurrent execution created by this method. */ public function leaveConcurrent(VirtualExecution $execution, Node $node = NULL, array $transitions = NULL) { $root = $execution->getScope(); $parent = $root->getParentExecution(); $exec = $parent->createExecution(true); $exec->setNode($node === NULL ? $execution->getNode() : $node); $root->setConcurrent(true); $this->createEventSubscriptions($root, $this->activityId, $execution->getProcessModel()->findNode($this->activityId)); $exec->takeAll($transitions); return $exec; }
/** * Have the given execution leave the activity. * * @param VirtualExecution $execution * @param array $transitions */ public function leave(VirtualExecution $execution, array $transitions = NULL) { $execution->getEngine()->notify(new ActivityCompletedEvent($execution->getNode()->getId(), $execution, $execution->getEngine())); $this->clearEventSubscriptions($execution, $execution->getNode()->getId()); $execution->takeAll($transitions); }