You are here

public function ResourceTypeRelationship::withRelatableResourceTypes in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/src/ResourceType/ResourceTypeRelationship.php \Drupal\jsonapi\ResourceType\ResourceTypeRelationship::withRelatableResourceTypes()

Establishes the relatable resource types of this field.

Parameters

array $resource_types: The array of relatable resource types.

Return value

static A new instance of the field with the given relatable resource types.

File

core/modules/jsonapi/src/ResourceType/ResourceTypeRelationship.php, line 34

Class

ResourceTypeRelationship
Specialization of a ResourceTypeField to represent a resource relationship.

Namespace

Drupal\jsonapi\ResourceType

Code

public function withRelatableResourceTypes(array $resource_types) {
  $relationship = new static($this->internalName, $this->publicName, $this->enabled, $this->hasOne);
  $relationship->relatableResourceTypes = $resource_types;
  return $relationship;
}