Drest\Service::runCallMethod PHP Method

runCallMethod() final public method

Run the call method required on this service object
final public runCallMethod ( )
    public final function runCallMethod()
    {
        // dispatch preServiceAction event
        $this->dm->triggerPreServiceActionEvent($this);
        $return = $this->getActionInstance()->execute();
        // dispatch postServiceAction event
        $this->dm->triggerPostServiceActionEvent($this);
        if ($return instanceof ResultSet) {
            $this->renderDeterminedRepresentation($return);
        }
    }

Usage Example

示例#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();
         }
     }
 }