setErrorHandler() public method

Set the error handler object
public setErrorHandler ( DrestCommon\Error\Handler\AbstractHandler $error_handler )
$error_handler DrestCommon\Error\Handler\AbstractHandler
Exemplo n.º 1
0
 /**
  * Execute a dispatched request
  * @param  string                            $namedRoute  - Define the named Route to be dispatched - bypasses the internal router lookup
  * @param  array                             $routeParams - Route parameters to be used for dispatching a namedRoute request
  * @throws Route\NoMatchException|\Exception
  */
 protected function execute($namedRoute = null, array $routeParams = array())
 {
     if (($route = $this->determineRoute($namedRoute, $routeParams)) instanceof RouteMetaData) {
         // Get the representation to be used - always successful or it throws an exception
         $representation = $this->getDeterminedRepresentation($route);
         // Configure push / pull exposure fields
         switch ($this->request->getHttpMethod()) {
             // Match on content option
             case Request::METHOD_GET:
                 $this->handlePullExposureConfiguration($route);
                 break;
                 // Match on content-type
             // Match on content-type
             case Request::METHOD_POST:
             case Request::METHOD_PUT:
             case Request::METHOD_PATCH:
                 $representation = $this->handlePushExposureConfiguration($route, $representation);
                 break;
         }
         // Set the matched service object and the error handler into the service class
         $this->service->setMatchedRoute($route);
         $this->service->setRepresentation($representation);
         $this->service->setErrorHandler($this->getErrorHandler());
         // Set up the service for a new request
         if ($this->service->setupRequest()) {
             $this->service->runCallMethod();
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Execute a dispatched request
  * @throws Route\NoMatchException|\Exception
  */
 protected function execute()
 {
     if (($route = $this->determineRoute()) instanceof RouteMetaData) {
         // Set the matched service object and the error handler into the service class
         $this->service->setMatchedRoute($route);
         // Get the representation to be used - always successful or it throws an exception
         $this->service->setRepresentation($this->representationManager->handleExposureSettingsFromHttpMethod($this->getRequest(), $route, $this->emr));
         $this->service->setErrorHandler($this->getErrorHandler());
         // Set up the service for a new request
         $this->service->setUpAndRunRequest();
     }
 }