PHP Interface Neomerx\JsonApi\Contracts\Encoder\EncoderInterface

Afficher le fichier Open project: neomerx/json-api Interface Usage Examples

Méthodes publiques

Méthode Description
encodeData ( object | array | Iterato\Iterator | null $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null ) : string Encode input as JSON API string.
encodeError ( Neomerx\JsonApi\Contracts\Document\ErrorInterface $error ) : string Encode error as JSON API string.
encodeErrors ( Neomerx\JsonApi\Contracts\Document\ErrorInterface[] | ErrorCollection $errors ) : string Encode errors as JSON API string.
encodeIdentifiers ( object | array | Iterato\Iterator | null $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null ) : string Encode input as JSON API string with a list of resource identifiers.
encodeMeta ( array | object $meta ) : string Encode input meta as JSON API string.
withJsonApiVersion ( mixed | null $meta = null ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface If called JSON API version information with optional meta will be added to a document.
withLinks ( array $links ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface Add links that will be encoded with data. Links must be in array format.
withMeta ( mixed | null $meta ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface Add meta information that will be encoded with data. If 'null' meta will not appear in a document.
withRelationshipRelatedLink ( object $resource, string $relationshipName, null | mixed $meta = null, boolean $treatAsHref = false ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface Add 'related' Link to top-level document's 'links' section for relationship specified.
withRelationshipSelfLink ( object $resource, string $relationshipName, null | mixed $meta = null, boolean $treatAsHref = false ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface Add 'self' Link to top-level document's 'links' section for relationship specified.

Method Details

encodeData() public méthode

Encode input as JSON API string.
public encodeData ( object | array | Iterato\Iterator | null $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null ) : string
$data object | array | Iterato\Iterator | null Data to encode.
$parameters Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface Encoding parameters.
Résultat string

encodeError() public méthode

Encode error as JSON API string.
public encodeError ( Neomerx\JsonApi\Contracts\Document\ErrorInterface $error ) : string
$error Neomerx\JsonApi\Contracts\Document\ErrorInterface
Résultat string

encodeErrors() public méthode

Encode errors as JSON API string.
public encodeErrors ( Neomerx\JsonApi\Contracts\Document\ErrorInterface[] | ErrorCollection $errors ) : string
$errors Neomerx\JsonApi\Contracts\Document\ErrorInterface[] | Neomerx\JsonApi\Exceptions\ErrorCollection
Résultat string

encodeIdentifiers() public méthode

Encode input as JSON API string with a list of resource identifiers.
public encodeIdentifiers ( object | array | Iterato\Iterator | null $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null ) : string
$data object | array | Iterato\Iterator | null Data to encode.
$parameters Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface Encoding parameters.
Résultat string

encodeMeta() public méthode

Encode input meta as JSON API string.
public encodeMeta ( array | object $meta ) : string
$meta array | object Meta information.
Résultat string

withJsonApiVersion() public méthode

If called JSON API version information with optional meta will be added to a document.
See also: http://jsonapi.org/format/#document-jsonapi-object
public withJsonApiVersion ( mixed | null $meta = null ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface
$meta mixed | null
Résultat Neomerx\JsonApi\Contracts\Encoder\EncoderInterface

withMeta() public méthode

Add meta information that will be encoded with data. If 'null' meta will not appear in a document.
public withMeta ( mixed | null $meta ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface
$meta mixed | null
Résultat Neomerx\JsonApi\Contracts\Encoder\EncoderInterface