Пример #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]));
 }
Пример #2
0
 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable $next
  * @return HtmlResponse
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $userId = $request->getAttribute('user_id');
     $invalidUser = true;
     $user = null;
     if ($userId) {
         $user = $this->userFinder->findById($userId);
         if ($user) {
             $invalidUser = false;
         }
     }
     return new HtmlResponse($this->templates->render('page::user-todo-form', ['invalidUser' => $invalidUser, 'user' => $user]));
 }
 /**
  * Create a 404 response.
  *
  * If we have a template renderer composed, renders the 404 template into
  * the response.
  *
  * @param Request $request
  * @param Response $response
  * @return Response
  */
 private function create404(Request $request, Response $response)
 {
     if ($this->template) {
         $response->getBody()->write($this->template->render($this->template404, ['uri' => $request->getUri()]));
     }
     return $response->withStatus(404);
 }
Пример #4
0
 /**
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @param callable $next
  * @return ResponseInterface
  */
 public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next)
 {
     return new HtmlResponse($this->templates->render('page::home'));
 }
Пример #5
0
 /**
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @param callable $next
  * @return ResponseInterface
  */
 public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next)
 {
     $users = $this->userFinder->findAll();
     return new HtmlResponse($this->templates->render('page::user-list', ['users' => $users]));
 }
Пример #6
0
 private function composeBody(array $messageData)
 {
     return $this->renderer->render(self::TEMPLATE, $messageData);
 }