getDeterminedRepresentation() public method

Detect an instance of a representation class using a matched route, or default representation classes
public getDeterminedRepresentation ( DrestCommon\Request\Request $request, RouteMetaData &$route = null ) : DrestCommon\Representation\AbstractRepresentation
$request DrestCommon\Request\Request
$route Drest\Mapping\RouteMetaData
return DrestCommon\Representation\AbstractRepresentation $representation
Beispiel #1
0
 /**
  * Handle an error by passing the exception to the registered error handler
  * @param  \Exception $e
  * @throws \Exception
  */
 private function handleError(\Exception $e)
 {
     $eh = $this->getErrorHandler();
     try {
         $representation = $this->representationManager->getDeterminedRepresentation($this->getRequest());
         $errorDocument = $representation->getDefaultErrorResponse();
         $eh->error($e, 500, $errorDocument);
     } catch (UnableToMatchRepresentationException $e) {
         $errorDocument = new ErrorResponseText();
         $eh->error($e, 500, $errorDocument);
     }
     $this->getResponse()->setStatusCode($eh->getResponseCode());
     $this->getResponse()->setHttpHeader('Content-Type', $errorDocument::getContentType());
     $this->getResponse()->setBody($errorDocument->render());
 }