src/Http/Middleware/ParsesServerRequests.php
protected function parseServerRequest(
        ServerRequestInterface $serverRequest,
        FactoryInterface $factory,
        StoreInterface $store,
        CodecMatcherInterface $codecMatcher,
        $resourceType,
        $resourceId,
        $relationshipName,
        $relationships
    ) {
        /** If the resource id is not valid, throw a 404 exception. */
        if ($resourceId && !$this->doesResourceExist($store, $resourceType, $resourceId)) {
            throw new JsonApiException([], 404);
        }

        /** Do content negotiation. */
        $this->doContentNegotiation($factory, $serverRequest, $codecMatcher);

        /** Parse the server request into a JSON API inbound request object. */
        $inboundRequest = $factory->createInboundRequest(
            $serverRequest->getMethod(),
            $resourceType,
            $resourceId,
            $relationshipName,
            $relationships,
            $this->decodeDocument($serverRequest),
            $this->parseQueryParameters($serverRequest, $factory->createQueryParametersParser())
        );

        /** Check that there is a JSON API document if one is required for the type of request. */
        if ($this->isExpectingDocument($inboundRequest) && !$inboundRequest->getDocument()) {
            throw new DocumentRequiredException();
        }

        return $inboundRequest;
    }
protected function parseServerRequest(
        ServerRequestInterface $serverRequest,
        FactoryInterface $factory,
        StoreInterface $store,
        CodecMatcherInterface $codecMatcher,
        $resourceType,
        $resourceId,
        $relationshipName,
        $relationships
    ) {
        /** If the resource id is not valid, throw a 404 exception. */
        if ($resourceId && !$this->doesResourceExist($store, $resourceType, $resourceId)) {
            throw new JsonApiException([], 404);
        }

        /** Do content negotiation. */
        $this->doContentNegotiation($factory, $serverRequest, $codecMatcher);

        /** Parse the server request into a JSON API inbound request object. */
        $inboundRequest = $factory->createInboundRequest(
            $serverRequest->getMethod(),
            $resourceType,
            $resourceId,
            $relationshipName,
            $relationships,
            $this->decodeDocument($serverRequest),
            $this->parseQueryParameters($serverRequest, $factory->createQueryParametersParser())
        );

        /** Check that there is a JSON API document if one is required for the type of request. */
        if ($this->isExpectingDocument($inboundRequest) && !$inboundRequest->getDocument()) {
            throw new DocumentRequiredException();
        }

        return $inboundRequest;
    }
protected function parseServerRequest ( ServerRequestInterface $ serverRequest , FactoryInterface $ factory , StoreInterface $ store , CodecMatcherInterface $ codecMatcher , $ resourceType , $ resourceId , $ relationshipName , $ relationships ) { /** If the resource id is not valid, throw a 404 exception. */ if ( $ resourceId && ! $ this -> doesResourceExist ( $ store , $ resourceType , $ resourceId ) ) { throw new JsonApiException ( [ ] , 404 ) ; } /** Do content negotiation. */ $ this -> doContentNegotiation ( $ factory , $ serverRequest , $ codecMatcher ) ; /** Parse the server request into a JSON API inbound request object. */ $ inboundRequest = $ factory -> createInboundRequest ( $ serverRequest -> getMethod ( ) , $ resourceType , $ resourceId , $ relationshipName , $ relationships , $ this -> decodeDocument ( $ serverRequest ) , $ this -> parseQueryParameters ( $ serverRequest , $ factory -> createQueryParametersParser ( ) ) ) ; /** Check that there is a JSON API document if one is required for the type of request. */ if ( $ this -> isExpectingDocument ( $ inboundRequest ) && ! $ inboundRequest -> getDocument ( ) ) { throw new DocumentRequiredException ( ) ; } return $ inboundRequest ; }
Parse a server request into a JSON API inbound request object.

This method will parse a server request into an inbound JSON API request
object that describes the type of JSON API request according to the spec's
definitions. It will throw a JSON API exception in any of the following
circumstances:

- There is a resource id and the type/id combination do not exist (404).
- The request fails content negotiation (406/415).
- The HTTP request body content does not decode as JSON (400).
- The HTTP request body does not contain a JSON API document but one is expected
for the request (400).
- Any of the JSON API query parameters do not comply with the spec (400).

This method expects information about the URL (resource type, id, etc)
to be provided as different frameworks may have access to this information
separately from the URL. E.g. some frameworks allow variables to be defined
on the route definition, or the variables may be available as route parameters.
As such, there is no provision for parsing the server request's URL into
the parameters, as it will always be more efficient to obtain these directly
from the framework-specific implementation.

@param ServerRequestInterface $serverRequest
@param FactoryInterface $factory
@param StoreInterface $store
@param CodecMatcherInterface $codecMatcher
@param string $resourceType
@param string|null $resourceId
@param string|null $relationshipName
@param bool $relationships
@return InboundRequestInterface
@throws JsonApiException
Parse a server request into a JSON API inbound request object .