Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Relationship.php

function 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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal