/** * @param TodoAssigneeWasReminded $event */ public function __invoke(TodoAssigneeWasReminded $event) { $user = $this->userFinder->findById($event->userId()->toString()); $todo = $this->todoFinder->findById($event->todoId()->toString()); $mail = new Mail\Message(); $mail->setBody("Hello {$user->name}. This a reminder for '{$todo->text}'. Don't be lazy!"); $mail->setFrom('*****@*****.**', 'Proophessor-do'); $mail->addTo($user->email, $user->name); $mail->setSubject('Proophessor-do Todo Reminder'); $this->mailer->send($mail); }
/** * @param TodoAssigneeWasReminded $event */ public function __invoke(TodoAssigneeWasReminded $event) { $user = null; $this->queryBus->dispatch(new GetUserById($event->userId()->toString()))->then(function ($result) use(&$user) { $user = $result; }); $todo = null; $this->queryBus->dispatch(new GetTodoById($event->todoId()->toString()))->then(function ($result) use(&$todo) { $todo = $result; }); $mail = new Mail\Message(); $mail->setBody("Hello {$user->name}. This a reminder for '{$todo->text}'. Don't be lazy!"); $mail->setFrom('*****@*****.**', 'Proophessor-do'); $mail->addTo($user->email, $user->name); $mail->setSubject('Proophessor-do Todo Reminder'); $this->mailer->send($mail); }
/** * @param TodoAssigneeWasReminded $event * @return void */ protected function whenTodoAssigneeWasReminded(TodoAssigneeWasReminded $event) { $this->reminder = $event->reminder(); }
/** * @param TodoAssigneeWasReminded $event * @return void */ public function onTodoAssigneeWasReminded(TodoAssigneeWasReminded $event) { $this->connection->update(Table::TODO_REMINDER, ['status' => $event->reminder()->status()->toString()], ['todo_id' => $event->todoId()->toString()]); }