-
Notifications
You must be signed in to change notification settings - Fork 67
Upgrade Notes
Passing Links, Meta and JSON API version information via Encoder parameters have been deprecated and removed from the code. They should be passed via with... methods e.g.
$encoder
->withLinks($links)
->withMeta($docMeta)
->withJsonApiVersion($versionMeta)
->encodeData(...);A new parameter array[] $includeRelationships was added to method Schema::getRelationships. The parameter contains a list of relationship names which will be included to output result as full resources (attributes and relationships). It could be used for more optimal data fetch requests to database. For example if a model Comment contains field author_id and $includeRelationships do not contain author an Author instance with empty attributes could be returned. It eliminates necessity to make request(s) to database for such cases.
The new parameter should be added to existing Schemas
class CommentSchema extends SchemaProvider
{
...
public function getRelationships($comment, array $includeRelationships)
{
...
}
...
}Fields $isShowSelf (default true) and $isShowSelfInIncluded (default false) were replaced with methods getResourceLinks and getIncludedResourceLinks (default implementation below). If you have not changed $isShowSelf and $isShowSelfInIncluded you do not need to make any changes in your code.
public function getResourceLinks($resource)
{
$links = [
LinkInterface::SELF => $this->getSelfSubLink($resource),
];
return $links;
}
public function getIncludedResourceLinks($resource)
{
return [];
}