Drest\Manager\Representation::determineRepresentationByHttpMethod PHP Method

determineRepresentationByHttpMethod() protected method

Determine the representation by inspecting the HTTP method
protected determineRepresentationByHttpMethod ( DrestCommon\Representation\AbstractRepresentation $representation, array $detectContentOptions = [] ) : DrestCommon\Representation\AbstractRepresentation | null
$representation DrestCommon\Representation\AbstractRepresentation
$detectContentOptions array - Eg array(self::DETECT_CONTENT_HEADER => 'Accept')
return DrestCommon\Representation\AbstractRepresentation | null
    protected function determineRepresentationByHttpMethod(AbstractRepresentation $representation, array $detectContentOptions = [])
    {
        switch ($this->request->getHttpMethod()) {
            // Match on content option
            case Request::METHOD_GET:
                // This representation matches the required media type requested by the client
                if ($representation->isExpectedContent($detectContentOptions, $this->request)) {
                    return $representation;
                }
                break;
                // Match on content-type
            // Match on content-type
            case Request::METHOD_POST:
            case Request::METHOD_PUT:
            case Request::METHOD_PATCH:
                if ($representation->getContentType() === $this->request->getHeaders('Content-Type')) {
                    return $representation;
                }
                break;
        }
        return null;
    }