PHP Interface WoohooLabs\Yin\JsonApi\Request\RequestInterface

Inheritance: extends Psr\Http\Message\ServerRequestInterface
Show file Open project: woohoolabs/yin Interface Usage Examples

Public Methods

Method Description
getCursorBasedPagination ( mixed $defaultCursor = null ) : CursorBasedPagination
getFiltering ( ) : array
getFilteringParam ( string $param, mixed | null $default = null ) : array | string
getFixedPageBasedPagination ( mixed $defaultPage = null ) : FixedPageBasedPagination
getIncludedFields ( string $resourceType ) : array Returns a list of field names for the given resource type which are required to be present in the response.
getIncludedRelationships ( string $baseRelationshipPath ) : array Returns a list of relationship paths for a given parent path.
getOffsetBasedPagination ( mixed $defaultOffset = null, mixed $defaultLimit = null ) : OffsetBasedPagination
getPageBasedPagination ( mixed $defaultPage = null, mixed $defaultSize = null ) : PageBasedPagination
getPagination ( ) : array | null
getQueryParam ( string $name, mixed $default = null ) : array | string Returns a query parameter with a name of $name if it is present in the request, or the $default value otherwise.
getResource ( ) : array | null Returns the "data" part of the request if it is present in the body, or null otherwise.
getResourceAttribute ( string $attribute, mixed | null $default = null ) : mixed | null
getResourceAttributes ( ) : array
getResourceId ( ) : string | null Returns the "id" key's value in the "data" part of the request if it is present in the body, or null otherwise.
getResourceType ( ) : string | null Returns the "type" key's value in the "data" part of the request if it is present in the body, or null otherwise.
getSorting ( ) : array
getToManyRelationship ( string $relationship ) : ToManyRelationship | null
getToOneRelationship ( string $relationship ) : ToOneRelationship | null
hasIncludedRelationships ( ) : boolean Determines if the request needs any relationships to be included.
isIncludedField ( string $resourceType, string $field ) : boolean Determines if a given field for a given resource type should be present in the response or not.
isIncludedRelationship ( string $baseRelationshipPath, string $relationshipName, array $defaultRelationships ) : boolean Determines if a given relationship name that is a child of the $baseRelationshipPath is required to be included in the response.
validateAcceptHeader ( ) Validates if the current request's Accept header conforms to the JSON API schema.
validateContentTypeHeader ( ) Validates if the current request's Content-Type header conforms to the JSON API schema.
validateQueryParams ( ) Validates if the current request's query parameters conform to the JSON API schema.
withQueryParam ( string $name, mixed $value ) Returns a query parameter with a name of $name if it is present in the request, or the $default value otherwise.

Method Details

getCursorBasedPagination() public method

public getCursorBasedPagination ( mixed $defaultCursor = null ) : CursorBasedPagination
$defaultCursor mixed
return WoohooLabs\Yin\JsonApi\Request\Pagination\CursorBasedPagination

getFiltering() public method

public getFiltering ( ) : array
return array

getFilteringParam() public method

public getFilteringParam ( string $param, mixed | null $default = null ) : array | string
$param string
$default mixed | null
return array | string

getFixedPageBasedPagination() public method

public getFixedPageBasedPagination ( mixed $defaultPage = null ) : FixedPageBasedPagination
$defaultPage mixed
return WoohooLabs\Yin\JsonApi\Request\Pagination\FixedPageBasedPagination

getIncludedFields() public method

Returns a list of field names for the given resource type which are required to be present in the response.
public getIncludedFields ( string $resourceType ) : array
$resourceType string
return array

getIncludedRelationships() public method

Returns a list of relationship paths for a given parent path.
public getIncludedRelationships ( string $baseRelationshipPath ) : array
$baseRelationshipPath string
return array

getOffsetBasedPagination() public method

public getOffsetBasedPagination ( mixed $defaultOffset = null, mixed $defaultLimit = null ) : OffsetBasedPagination
$defaultOffset mixed
$defaultLimit mixed
return WoohooLabs\Yin\JsonApi\Request\Pagination\OffsetBasedPagination

getPageBasedPagination() public method

public getPageBasedPagination ( mixed $defaultPage = null, mixed $defaultSize = null ) : PageBasedPagination
$defaultPage mixed
$defaultSize mixed
return WoohooLabs\Yin\JsonApi\Request\Pagination\PageBasedPagination

getPagination() public method

public getPagination ( ) : array | null
return array | null

getQueryParam() public method

Returns a query parameter with a name of $name if it is present in the request, or the $default value otherwise.
public getQueryParam ( string $name, mixed $default = null ) : array | string
$name string
$default mixed
return array | string

getResource() public method

Returns the "data" part of the request if it is present in the body, or null otherwise.
public getResource ( ) : array | null
return array | null

getResourceAttribute() public method

public getResourceAttribute ( string $attribute, mixed | null $default = null ) : mixed | null
$attribute string
$default mixed | null
return mixed | null

getResourceAttributes() public method

public getResourceAttributes ( ) : array
return array

getResourceId() public method

Returns the "id" key's value in the "data" part of the request if it is present in the body, or null otherwise.
public getResourceId ( ) : string | null
return string | null

getResourceType() public method

Returns the "type" key's value in the "data" part of the request if it is present in the body, or null otherwise.
public getResourceType ( ) : string | null
return string | null

getSorting() public method

public getSorting ( ) : array
return array

getToManyRelationship() public method

public getToManyRelationship ( string $relationship ) : ToManyRelationship | null
$relationship string
return WoohooLabs\Yin\JsonApi\Hydrator\Relationship\ToManyRelationship | null

getToOneRelationship() public method

public getToOneRelationship ( string $relationship ) : ToOneRelationship | null
$relationship string
return WoohooLabs\Yin\JsonApi\Hydrator\Relationship\ToOneRelationship | null

hasIncludedRelationships() public method

Determines if the request needs any relationships to be included.

isIncludedField() public method

Determines if a given field for a given resource type should be present in the response or not.
public isIncludedField ( string $resourceType, string $field ) : boolean
$resourceType string
$field string
return boolean

isIncludedRelationship() public method

Determines if a given relationship name that is a child of the $baseRelationshipPath is required to be included in the response.
public isIncludedRelationship ( string $baseRelationshipPath, string $relationshipName, array $defaultRelationships ) : boolean
$baseRelationshipPath string
$relationshipName string
$defaultRelationships array
return boolean

validateAcceptHeader() public method

Validates if the current request's Accept header conforms to the JSON API schema.

validateContentTypeHeader() public method

Validates if the current request's Content-Type header conforms to the JSON API schema.

validateQueryParams() public method

According to the JSON API specification "Implementation specific query parameters MUST adhere to the same constraints as member names with the additional requirement that they MUST contain at least one non a-z character (U+0061 to U+007A)".
public validateQueryParams ( )

withQueryParam() public method

Returns a query parameter with a name of $name if it is present in the request, or the $default value otherwise.
public withQueryParam ( string $name, mixed $value )
$name string
$value mixed