/** * {@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); }