| @@ 12-30 (lines=19) @@ | ||
| 9 | use Psr\Http\Server\RequestHandlerInterface; |
|
| 10 | use Zend\Diactoros\Response\HtmlResponse; |
|
| 11 | ||
| 12 | class NotAllowedDecorator extends ExceptionDecorator |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @param ServerRequestInterface $request |
|
| 16 | * @param RequestHandlerInterface $handler |
|
| 17 | * @return ResponseInterface |
|
| 18 | */ |
|
| 19 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
| 20 | { |
|
| 21 | $body = $this->viewEngine->render('error/not-allowed'); |
|
| 22 | $body = $this->viewEngine->render($this->getLayout(), [ |
|
| 23 | 'content' => $body, |
|
| 24 | ]); |
|
| 25 | ||
| 26 | return $this->getResponseWithBodyAndStatus(new HtmlResponse(''), $body, 405); |
|
| 27 | ||
| 28 | return parent::process($request, $handler); |
|
| 29 | } |
|
| 30 | } |
|
| @@ 14-30 (lines=17) @@ | ||
| 11 | use Zend\Diactoros\Response; |
|
| 12 | use Zend\Diactoros\Stream; |
|
| 13 | ||
| 14 | class NotFoundDecorator extends ExceptionDecorator implements MiddlewareInterface |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * @param ServerRequestInterface $request |
|
| 18 | * @param RequestHandlerInterface $handler |
|
| 19 | * @return ResponseInterface |
|
| 20 | */ |
|
| 21 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
| 22 | { |
|
| 23 | $body = $this->viewEngine->render('error/not-found'); |
|
| 24 | $body = $this->viewEngine->render($this->getLayout(), [ |
|
| 25 | 'content' => $body, |
|
| 26 | ]); |
|
| 27 | ||
| 28 | return $this->getResponseWithBodyAndStatus(new Response\HtmlResponse(''), $body, 404); |
|
| 29 | } |
|
| 30 | } |
|