Пример #1
0
 /**
  * Get the count of a task in the history in a given state
  *
  * @param TaskSchema       $task
  * @param HistoryItemState $state
  * @return int
  */
 public function countTask(TaskSchema $task, HistoryItemState $state)
 {
     $cache_key = 'T:' . $task->getActivityName() . ':' . $task->getActivityVersion() . ':' . $state->key();
     if (array_key_exists($cache_key, $this->completion_cache)) {
         return $this->completion_cache[$cache_key];
     }
     $count = 0;
     foreach ($this->history as $history_item) {
         /** @var WorkflowHistoryItem $history_item */
         if ($task->getActivityName() == $history_item->getActivityName() && $task->getActivityVersion() == $history_item->getActivityVersion() && $history_item->getState() == $state) {
             $count++;
         }
     }
     $this->completion_cache[$cache_key] = $count;
     return $count;
 }
Пример #2
0
 /**
  * Execute a task
  *
  * @param TaskSchema $task
  * @param WorkEvent  $event
  */
 protected function executeTask(TaskSchema $task, WorkEvent $event)
 {
     $memory_pool = $this->getWorkflow()->getJailMemoryPool() ? JailedMemoryPool::jail($this->getMemoryPool(), ':' . $event->getExecutionId()) : $this->getMemoryPool();
     $class = $task->getClass();
     /** @var TaskInterface $obj */
     $obj = new $class($memory_pool, $event->getInput(), $this->getAuxPayload());
     if (!$obj instanceof TaskInterface) {
         throw new \DomainException("Class for task " . $task->getActivityName() . " is not a TaskInterface");
     }
     $obj->execute($event);
 }