You are here

protected function ResourceTypeRepository::isReferenceFieldDefinition in JSON:API 8.2

Same name and namespace in other branches
  1. 8 src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::isReferenceFieldDefinition()

Determines if a given field definition is a reference field.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition to inspect.

Return value

bool TRUE if the field definition is found to be a reference field. FALSE otherwise.

1 call to ResourceTypeRepository::isReferenceFieldDefinition()
ResourceTypeRepository::calculateRelatableResourceTypes in src/ResourceType/ResourceTypeRepository.php
Calculates relatable JSON:API resource types for a given resource type.

File

src/ResourceType/ResourceTypeRepository.php, line 416

Class

ResourceTypeRepository
Provides a repository of all JSON:API resource types.

Namespace

Drupal\jsonapi\ResourceType

Code

protected function isReferenceFieldDefinition(FieldDefinitionInterface $field_definition) {

  /* @var \Drupal\Core\Field\TypedData\FieldItemDataDefinition $item_definition */
  $item_definition = $field_definition
    ->getItemDefinition();
  $main_property = $item_definition
    ->getMainPropertyName();
  $property_definition = $item_definition
    ->getPropertyDefinition($main_property);
  return $property_definition instanceof DataReferenceTargetDefinition;
}