예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function execute(EngineInterface $engine)
 {
     $execution = $engine->findExecution($this->executionId);
     $node = $execution->getProcessModel()->findNode($this->nodeId);
     $execution->setTimestamp(microtime(true));
     $execution->setNode($node);
     $engine->debug('{execution} entering {node}', ['execution' => (string) $execution, 'node' => (string) $node]);
     $engine->notify(new EnterNodeEvent($node, $execution));
     $this->executeNode($node, $execution);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function execute(EngineInterface $engine)
 {
     $execution = $engine->findExecution(new UUID($this->executionId));
     $node = $execution->getNode();
     $vars = unserialize($this->variables);
     $delegation = unserialize($this->delegation);
     $execution->wakeUp();
     $engine->debug('Signaling <{signal}> to {execution}', ['signal' => $this->signal === NULL ? 'NULL' : $this->signal, 'execution' => (string) $execution]);
     $engine->notify(new SignalNodeEvent($node, $execution, $this->signal, $vars, $delegation));
     $this->singalExecution($node, $execution, $vars, $delegation);
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function execute(EngineInterface $engine)
 {
     $engine->debug('Starting process {process} at {node}', ['process' => (string) $this->model->getId(), 'node' => (string) $this->startNode]);
     $process = $this->createRootExecution($engine);
     $engine->debug('Created {execution}', ['execution' => (string) $process]);
     foreach ($this->variables as $k => $v) {
         $process->setVariable($k, $v);
     }
     $engine->registerExecution($process);
     $engine->notify(new StartProcessEvent($this->startNode, $process));
     $process->execute($this->startNode);
     return $process;
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function execute(EngineInterface $engine)
 {
     $execution = $engine->findExecution($this->executionId);
     if ($execution->isConcurrent()) {
         if (1 === count($execution->findConcurrentExecutions())) {
             $parent = $execution->getParentExecution();
             foreach ($execution->findChildExecutions() as $child) {
                 $parent->registerChildExecution($child);
             }
             $parent->setNode($execution->getNode());
             $parent->setTransition($execution->getTransition());
             $parent->setTimestamp(microtime(true));
             $parent->setActive(true);
             $parent->markModified(true);
             $engine->debug('Merged concurrent {execution} into {root}', ['execution' => (string) $execution, 'root' => (string) $parent]);
             $execution->terminate(false);
             return $parent->take($this->transitionId);
         }
     }
     $trans = $this->findTransition($execution);
     if (!$trans->isEnabled($execution)) {
         if ($execution->isConcurrent() && 0 == count($execution->findConcurrentExecutions())) {
             $execution->terminate(false);
             $parent = $execution->getParentExecution();
             $parent->setTimestamp(microtime(true));
             $parent->setActive(true);
             $parent->terminate();
         } else {
             $execution->terminate();
         }
         return;
     }
     $node = $execution->getNode();
     $engine->debug('{execution} leaves {node}', ['execution' => (string) $execution, 'node' => (string) $node]);
     $engine->notify(new LeaveNodeEvent($node, $execution));
     $engine->debug('{execution} taking {transition}', ['execution' => (string) $execution, 'transition' => (string) $trans]);
     $engine->notify(new TakeTransitionEvent($trans, $execution));
     $execution->setTimestamp(microtime(true));
     $execution->setTransition($trans);
     $execution->execute($execution->getProcessModel()->findNode($trans->getTo()));
 }
예제 #5
0
 /**
  * Introduce a new concurrent root as parent of this execution.
  * 
  * @param boolean $active
  * @return Execution
  */
 public function introduceConcurrentRoot($active = false)
 {
     $this->engine->debug('Introducing concurrent root into {execution}', ['execution' => (string) $this]);
     $parent = $this->parentExecution;
     $root = new static(UUID::createRandom(), $this->engine, $this->model, $parent);
     $root->setActive($active);
     $root->variables = $this->variables;
     $root->setState(self::STATE_SCOPE, $this->isScope());
     if ($parent !== NULL) {
         foreach ($parent->childExecutions as $index => $exec) {
             if ($exec === $this) {
                 unset($parent->childExecutions[$index]);
             }
         }
     }
     $this->setParentExecution($root);
     $this->setState(self::STATE_CONCURRENT, true);
     $this->setState(self::STATE_SCOPE, false);
     $this->variables = [];
     $this->markModified();
     $this->engine->registerExecution($root);
     return $root;
 }