public static function create($description) { $id = TaskId::generate(); $task = new self($id, $description); $task->recordThat(new TaskCreatedEvent($id, $description)); return $task; }
public function handleStartTaskListCommand(Commands\StartTaskListCommand $command) { $taskList = TaskList::start(TaskListId::generate()); foreach ($command->tasks as $task) { $taskList->add(TaskId::generate(), $task); } $this->taskListRepository->save($taskList); }
public function __construct(\Generator $coroutine, $taskId = 0, $parentId = 0, Context $context = null) { $this->coroutine = $coroutine; $this->taskId = $taskId ? $taskId : TaskId::create(); $this->parentId = $parentId; if ($context) { $this->context = $context; } else { $this->context = new Context(); } $this->scheduler = new Scheduler($this); }