Relationship
class Relationship implements TopLevelDataInterface (View source)
| internal | JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it. |
Represents references from one resource object to other resource object(s).
Properties
| protected ResourceObject | $context | The context resource object of the relationship. |
|
| protected RelationshipData | $data | The data of the relationship object. |
|
| protected string | $fieldName | The relationship's public field name. |
|
| protected LinkCollection | $links | The relationship object's links. |
|
| protected array | $meta | The relationship object's meta member. |
Methods
Relationship constructor.
Creates a new Relationship from an entity reference field.
Gets context resource object of the relationship.
Gets the relationship object's public field name.
Gets the relationship object's links.
Gets the relationship object's metadata.
Returns the data that was omitted from the JSON:API document.
Merges the object's meta member with the top-level meta member.
Builds a LinkCollection for the given entity reference field.
Details
protected
__construct(string $public_field_name, RelationshipData $data, LinkCollection $links, array $meta, ResourceObject $context)
Relationship constructor.
This constructor is protected by design. To create a new relationship, use static::createFromEntityReferenceField().
static Relationship
createFromEntityReferenceField(ResourceObject $context, EntityReferenceFieldItemListInterface $field, LinkCollection $links = NULL, array $meta = [])
Creates a new Relationship from an entity reference field.
ResourceObject
getContext()
Gets context resource object of the relationship.
string
getFieldName()
Gets the relationship object's public field name.
Data
getData()
Gets the relationship object's data.
LinkCollection
getLinks()
Gets the relationship object's links.
array
getMeta()
Gets the relationship object's metadata.
OmittedData
getOmissions()
Returns the data that was omitted from the JSON:API document.
LinkCollection
getMergedLinks(LinkCollection $top_level_links)
Merges the object's links with the top-level links.
array
getMergedMeta(array $top_level_meta)
Merges the object's meta member with the top-level meta member.
static protected LinkCollection
buildLinkCollectionFromEntityReferenceField(ResourceObject $context, EntityReferenceFieldItemListInterface $field, LinkCollection $links)
Builds a LinkCollection for the given entity reference field.