Esempio n. 1
0
 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable $next
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $userId = $request->getAttribute('user_id');
     $user = $this->userFinder->findById($userId);
     $todos = $this->todoFinder->findByAssigneeId($userId);
     return new HtmlResponse($this->templates->render('page::user-todo-list', ['user' => $user, 'todos' => $todos]));
 }
 /**
  * @test
  * @dataProvider objectsData
  * @param \stdClass $todo
  * @param \stdClass $user
  */
 public function it_sends_email_to_the_assignee(\stdClass $todo, \stdClass $user)
 {
     $this->todoFinder->expects($this->once())->method('findById')->with($todo->id)->will($this->returnValue($todo));
     $this->userFinder->expects($this->once())->method('findById')->with($user->id)->will($this->returnValue($user));
     $this->mailer->expects($this->once())->method('send')->with($this->isInstanceOf(Message::class));
     $action = $this->action;
     $action($this->getEvent($todo->id));
 }
 /**
  * @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 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);
 }