Exemplo n.º 1
0
 /**
  * @param UpdateTask $command
  */
 public function handle(UpdateTask $command)
 {
     $oldTask = $this->tasksRepository->findOne(['id' => $command->id]);
     $oldTask->updateWithCommand($command);
     $this->tasksRepository->update($oldTask);
     // throw update event
 }
Exemplo n.º 2
0
 /**
  * @param CreateTask $createTaskCommand
  */
 public function handle(CreateTask $createTaskCommand)
 {
     /** @var TodoList $list */
     $list = $this->listsRepository->findOne(['id' => $createTaskCommand->listId]);
     $task = $this->taskFactory->createFromArray(['id' => $this->idGenerator->generateId(), 'title' => $createTaskCommand->title, 'content' => $createTaskCommand->content, 'list' => $list, 'finished' => $createTaskCommand->finished, 'deleted' => null]);
     $list->addTask($task);
     $this->tasksRepository->insert($task);
     // throw create event
 }