public function forbidden(ServerRequestInterface $request, ResponseInterface $response)
    {
        $contentType = $this->determineContentType($request);
        switch ($contentType) {
            case 'application/json':
                $output = $this->renderJsonErrorMessage();
                break;

            case 'text/html':
                $output = $this->renderHtmlErrorMessage();
                break;

            default:
                throw new Exception('Cannot render unknown content type ' . $contentType);
        }

        return $response
                ->withStatus(403)
                ->withHeader('Content-type', $contentType)
                ->write($output);
    }
public function forbidden(ServerRequestInterface $request, ResponseInterface $response)
    {
        $contentType = $this->determineContentType($request);
        switch ($contentType) {
            case 'application/json':
                $output = $this->renderJsonErrorMessage();
                break;

            case 'text/html':
                $output = $this->renderHtmlErrorMessage();
                break;

            default:
                throw new Exception('Cannot render unknown content type ' . $contentType);
        }

        return $response
                ->withStatus(403)
                ->withHeader('Content-type', $contentType)
                ->write($output);
    }
public function forbidden ( ServerRequestInterface $ request , ResponseInterface $ response ) { $ contentType = $ this -> determineContentType ( $ request ) ; switch ( $ contentType ) { case 'application/json' : $ output = $ this -> renderJsonErrorMessage ( ) ; break ; case 'text/html' : $ output = $ this -> renderHtmlErrorMessage ( ) ; break ; default : throw new Exception ( 'Cannot render unknown content type ' . $ contentType ) ; } return $ response -> withStatus ( 403 ) -> withHeader ( 'Content-type' , $ contentType ) -> write ( $ output ) ; }
Forbidden HTTP 403 Response

Code borrowed and modified from Slim Error
Respond with HTTP 403 Forbidden
@param ServerRequestInterface $request   The most recent Request object
@param ResponseInterface      $response  The most recent Response object
@return HTTP 403 Forbidden
Forbidden HTTP 403 Response