/** * 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(); } } }
/** * 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(); } }
/** * Handle an error - set the resulting error document to the response object * @param \Exception $e * @param integer $defaultResponseCode the default response code to use if no match on exception type occurs * @param ResponseInterface $errorDocument * @return ResultSet the error result set */ public function handleError(\Exception $e, $defaultResponseCode = 500, ResponseInterface $errorDocument = null) { return $this->service->handleError($e, $defaultResponseCode, $errorDocument); }
/** * Get the service action registry * @return ServiceActionRegistry */ public function getServiceActionRegistry() { return $this->service->getServiceActionRegistry(); }