/**
  * @param TodoWasMarkedAsExpired $event
  * @return void
  */
 public function __invoke(TodoWasMarkedAsExpired $event)
 {
     $todo = $this->todoFinder->findById($event->todoId()->toString());
     $user = $this->userFinder->findById($todo->assignee_id);
     $message = sprintf('Hi %s! Just a heads up: your todo `%s` has expired on %s.', $user->name, $todo->text, $todo->deadline);
     $mail = new Mail\Message();
     $mail->setBody($message);
     $mail->setEncoding('utf-8');
     $mail->setFrom('*****@*****.**', 'Proophessor-do');
     $mail->addTo($user->email, $user->name);
     $mail->setSubject('Proophessor-do Todo expired');
     $this->mailer->send($mail);
 }
예제 #2
0
 /**
  * @param TodoWasMarkedAsExpired $event
  */
 protected function whenTodoWasMarkedAsExpired(TodoWasMarkedAsExpired $event)
 {
     $this->status = $event->newStatus();
 }
예제 #3
0
 /**
  * @param TodoWasMarkedAsExpired $event
  */
 public function onTodoWasMarkedAsExpired(TodoWasMarkedAsExpired $event)
 {
     $this->connection->update(Table::TODO, ['status' => $event->newStatus()->toString()], ['id' => $event->todoId()->toString()]);
 }
 public function getEvent($todoId)
 {
     return TodoWasMarkedAsExpired::fromStatus(TodoId::fromString($todoId), TodoStatus::fromString(TodoStatus::OPEN), TodoStatus::fromString(TodoStatus::EXPIRED));
 }
예제 #5
0
 /**
  * @param TodoWasMarkedAsExpired $event
  * @throws UserNotFound if data of the the assigned user can not be found
  */
 public function onTodoWasMarkedAsExpired(TodoWasMarkedAsExpired $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, expired_todos = expired_todos + 1 WHERE id = :assignee_id', Table::USER));
     $stmt->bindValue('assignee_id', $user->id);
     $stmt->execute();
 }