Skip to content

Files

Latest commit

 Cannot retrieve latest commit at this time.

History

History
27 lines (17 loc) · 1.41 KB

05-documents.md

File metadata and controls

27 lines (17 loc) · 1.41 KB

back to README

Documents

Documents are the root objects for a request body (post, patch) or response body (Dogado\JsonApi\Model\Document\DocumentInterface).

A document contains "data" (collection of resources) and can contain meta information, errors, links and related resources ("includes").

Document Serializer

The document serializer (a class implementing Dogado\JsonApi\Serializer\DocumentSerializerInterface) is responsible for turning document objects (and their resources) into a php array in JSON API structure which can be JSON encoded and returned as response. The default serializer should be a good choice, but it's also possible to use a custom serializer.

The default serializer will remove empty "data" if "errors" or "meta" is available. It will also remove empty data in relationship if "meta" or "links" is available for a relationship. If empty data should be retained, the default serializer offers the option keepEmptyData as first constructor argument.

Document Deserializer

The document deserializer (a class implementing Dogado\JsonApi\Serializer\DocumentDeserializerInterface) is responsible for turning php arrays into document objects (and their resources). The default deserializer should be a good choice, but it's also possible to use a custom deserializer.


prev: Links | back to README | next: Errors