Esempio n. 1
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     $id = $request->getAttribute('id');
     if (!($comment = $this->repository->find($id))) {
         return $response->withStatus(404, 'post not found');
     }
     $this->view->render($response, 'post.phtml', ['comment' => new CommentViewModel($comment)]);
     return $response;
 }
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     $id = $request->getAttribute('id');
     $secret = $request->getAttribute('secret');
     if ($secret !== $this->secret) {
         return $response->withStatus(400, 'not authenticated');
     }
     $comment = $this->repository->load($id);
     $this->repository->delete($comment);
 }
Esempio n. 3
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     $comment = $this->repository->getMostRecent();
     $this->view->render($response, 'post.phtml', ['comment' => new CommentViewModel($comment)]);
 }