Example #1
0
 /**
  * {@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);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $context = $execution->getExpressionContext();
     $definition = $execution->getEngine()->getRepositoryService()->createProcessDefinitionQuery()->processDefinitionKey($this->processDefinitionKey)->findOne();
     $execution->getEngine()->debug('Starting process {process} from call activity "{task}"', ['process' => $this->processDefinitionKey, 'task' => $this->getStringValue($this->name, $context)]);
     $start = $definition->getModel()->findInitialNodes();
     if (count($start) !== 1) {
         throw new \RuntimeException(sprintf('Missing single non start event in process %s', $definition->getKey()));
     }
     $startNode = array_shift($start);
     $sub = $execution->createNestedExecution($definition->getModel(), $startNode, true, true);
     foreach ($this->inputs as $target => $source) {
         if ($source instanceof ExpressionInterface) {
             $sub->setVariable($target, $source($context));
         } elseif ($execution->hasVariable($source)) {
             $sub->setVariable($target, $execution->getVariable($source));
         }
     }
     $execution->waitForSignal();
     $sub->execute($startNode);
 }