setupRequest() protected method

Called on successful routing of a service call Prepares the service to a request to be rendered
protected setupRequest ( ) : boolean
return boolean $result - if false then fail fast no call to runCallMethod() should be made.
示例#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();
         }
     }
 }