Drest\Manager\Representation::handleExposureSettingsFromHttpMethod PHP Method

handleExposureSettingsFromHttpMethod() public method

public handleExposureSettingsFromHttpMethod ( DrestCommon\Request\Request $request, RouteMetaData $route, Drest\EntityManagerRegistry $emr ) : DrestCommon\Representation\AbstractRepresentation
$request DrestCommon\Request\Request
$route Drest\Mapping\RouteMetaData
$emr Drest\EntityManagerRegistry
return DrestCommon\Representation\AbstractRepresentation
    public function handleExposureSettingsFromHttpMethod($request, $route, EntityManagerRegistry $emr)
    {
        $this->emr = $emr;
        $this->request = $request;
        $representation = $this->getDeterminedRepresentation($request, $route);
        // If expose setting lookup isn't disabled, determine it
        if (!$route->isExposeDisabled()) {
            switch ($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;
            }
        }
        return $representation;
    }

Usage Example

Beispiel #1
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();
     }
 }