function Relationship::__construct

Same name and namespace in other branches
  1. 8.9.x core/modules/jsonapi/src/JsonApiResource/Relationship.php \Drupal\jsonapi\JsonApiResource\Relationship::__construct()
  2. 10 core/modules/jsonapi/src/JsonApiResource/Relationship.php \Drupal\jsonapi\JsonApiResource\Relationship::__construct()
  3. 11.x core/modules/jsonapi/src/JsonApiResource/Relationship.php \Drupal\jsonapi\JsonApiResource\Relationship::__construct()

Relationship constructor.

This constructor is protected by design. To create a new relationship, use static::createFromEntityReferenceField().

Parameters

string $public_field_name: The public field name of the relationship field.

\Drupal\jsonapi\JsonApiResource\RelationshipData $data: The relationship data.

\Drupal\jsonapi\JsonApiResource\LinkCollection $links: Any links for the resource object, if a `self` link is not provided, one will be automatically added if the resource is locatable and is not internal.

array $meta: Any relationship metadata.

\Drupal\jsonapi\JsonApiResource\ResourceObject $context: The relationship's context resource object. Use the self::withContext() method to establish a context.

See also

\Drupal\jsonapi\JsonApiResource\Relationship::createFromEntityReferenceField()

File

core/modules/jsonapi/src/JsonApiResource/Relationship.php, line 93

Class

Relationship
Represents references from one resource object to other resource object(s).

Namespace

Drupal\jsonapi\JsonApiResource

Code

protected function __construct($public_field_name, RelationshipData $data, LinkCollection $links, array $meta, ResourceObject $context) {
    $this->fieldName = $public_field_name;
    $this->data = $data;
    $this->links = $links->withContext($this);
    $this->meta = $meta;
    $this->context = $context;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.