Пример #1
0
 /**
  * @return TaskId
  */
 public function taskId()
 {
     if (is_null($this->taskId)) {
         $this->taskId = TaskId::fromString($this->aggregateId());
     }
     return $this->taskId;
 }
 /**
  * @return Task\TaskId
  */
 public function taskId()
 {
     if (is_null($this->taskId)) {
         $this->taskId = Task\TaskId::fromString($this->payload['task_id']);
     }
     return $this->taskId;
 }
 /**
  * @return TaskId[]
  */
 public function tasks()
 {
     if (is_null($this->tasks)) {
         $this->tasks = array_map(function ($taskId) {
             return TaskId::fromString($taskId);
         }, $this->payload['task_list']);
     }
     return $this->tasks;
 }
Пример #4
0
 /**
  * @test
  */
 function it_can_be_reconstituted_with_a_task_list()
 {
     $task1 = TaskId::generate();
     $task2 = TaskId::generate();
     $process = Process::withTaskList([$task1, $task2], ProcessId::generate(), ProcessType::linearMessaging());
     $this->assertTrue($task1->equals($process->tasks()[0]));
     $this->assertTrue($task2->equals($process->tasks()[1]));
     $this->assertTrue(ProcessType::linearMessaging()->equals($process->type()));
 }
Пример #5
0
 /**
  * @param TaskId $taskId
  */
 private function insertTaskIfDataIsComplete(TaskId $taskId)
 {
     if (isset($this->tasksEvents[$taskId->toString()]) && count($this->tasksEvents[$taskId->toString()]) >= 2) {
         $taskWasSetUp = null;
         $taskWasAddedToProcess = null;
         foreach ($this->tasksEvents[$taskId->toString()] as $event) {
             if ($event instanceof TaskWasSetUp) {
                 $taskWasSetUp = $event;
                 continue;
             }
             if ($event instanceof TaskWasAddedToProcess) {
                 $taskWasAddedToProcess = $event;
                 continue;
             }
         }
         if (!is_null($taskWasSetUp) && !is_null($taskWasAddedToProcess)) {
             $this->connection->insert(Tables::TASK, ['id' => $taskWasSetUp->taskId()->toString(), 'type' => $taskWasSetUp->taskType()->toString(), 'processing_type' => $taskWasSetUp->processingType()->of(), 'metadata' => json_encode($taskWasSetUp->taskMetadata()->toArray()), 'workflow_id' => $taskWasAddedToProcess->workflowId()->toString(), 'process_id' => $taskWasAddedToProcess->processId()->toString(), 'message_handler_id' => $taskWasSetUp->messageHandlerId()]);
         }
         unset($this->tasksEvents[$taskId->toString()]);
     }
 }
 /**
  * @return TaskId
  */
 public function previousTaskId()
 {
     return TaskId::fromString($this->payload['previous_task_id']);
 }
Пример #7
0
 /**
  * @return string representation of the unique identifier of the aggregate root
  */
 protected function aggregateId()
 {
     return $this->id->toString();
 }
Пример #8
0
 /**
  * @param TaskId $other
  * @return bool
  */
 public function equals(TaskId $other)
 {
     return $this->toString() === $other->toString();
 }
Пример #9
0
 /**
  * @param TaskId $taskId
  * @return TaskNotFound
  */
 public static function withId(TaskId $taskId)
 {
     return new self(sprintf('Task with id %s could not be found', $taskId->toString()));
 }
 /**
  * @param TaskId $taskId
  * @return Task
  */
 public function get(TaskId $taskId)
 {
     return $this->getAggregateRoot($taskId->toString());
 }
 /**
  * @return TaskId
  */
 public function taskId()
 {
     return TaskId::fromString($this->payload['task_id']);
 }