/** * {@inheritdoc} */ public function interrupt(VirtualExecution $execution, array $transitions = NULL) { $engine = $execution->getEngine(); $root = $execution->getScope(); $params = ['e1' => $root->getId()]; $i = 1; foreach ($root->findChildExecutions() as $child) { $params['e' . ++$i] = $child->getId(); } $placeholders = implode(', ', array_map(function ($p) { return ':' . $p; }, array_keys($params))); $stmt = $engine->prepareQuery("SELECT `id` FROM `#__bpmn_user_task` WHERE `execution_id` IN ({$placeholders})"); $stmt->bindAll($params); $stmt->transform('id', new UUIDTransformer()); $stmt->execute(); foreach ($stmt->fetchColumns('id') as $taskId) { $engine->executeCommand(new RemoveUserTaskCommand($taskId)); } parent::interrupt($execution, $transitions); }
public function processSignal(VirtualExecution $execution, $signal, array $variables = [], array $delegation = []) { $startNode = $execution->getProcessModel()->findNode($this->startNodeId); $root = $execution->getScope(); $scope = $this->findScopeActivity($execution); if (!$this->isInterrupting()) { return $scope->leaveConcurrent($root, $startNode); } // Kill all remaining concurrent executions within the scope activity: foreach ($root->findChildExecutions() as $child) { $child->terminate(false); } $scope->clearEventSubscriptions($root, $scope->getActivityId()); $root->setNode($this->findScopeNode($root)); $root->setActive(false); $root->waitForSignal(); $sub = $root->createExecution(false); $sub->setNode($startNode); $sub->waitForSignal(); $sub->getEngine()->notify(new ActivityCanceledEvent($this->attachedTo, $sub, $sub->getEngine())); // Delegate received signal to event sub process start event. $sub->signal($signal, $variables); }
/** * 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; }