Beispiel #1
0
 /**
  * @param TodoWasMarkedAsDone $event
  * @throws UserNotFound if data of the the assigned user can not be found
  */
 public function onTodoWasMarkedAsDone(TodoWasMarkedAsDone $event)
 {
     $user = $this->userFinder->findUserOfTodo($event->todoId()->toString());
     if (!$user) {
         throw new UserNotFound(sprintf("Data of the assigned user of the todo %s cannot be found", $event->todoId()->toString()));
     }
     $stmt = $this->connection->prepare(sprintf('UPDATE %s SET open_todos = open_todos - 1, done_todos = done_todos + 1 WHERE id = :assignee_id', Table::USER));
     $stmt->bindValue('assignee_id', $user->id);
     $stmt->execute();
 }
Beispiel #2
0
 /**
  * @param TodoWasMarkedAsDone $event
  */
 protected function whenTodoWasMarkedAsDone(TodoWasMarkedAsDone $event)
 {
     $this->status = $event->newStatus();
 }
 /**
  * @param TodoWasMarkedAsDone $event
  */
 public function onTodoWasMarkedAsDone(TodoWasMarkedAsDone $event)
 {
     $this->connection->update(Table::TODO, ['status' => $event->newStatus()->toString()], ['id' => $event->todoId()->toString()]);
 }