You are here

protected static function ResourceTestBase::isReferenceFieldDefinition in JSON:API 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::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 ResourceTestBase::isReferenceFieldDefinition()
ResourceTestBase::getRelationshipFieldNames in tests/src/Functional/ResourceTestBase.php
Gets a list of relationship field names for the resource type under test.

File

tests/src/Functional/ResourceTestBase.php, line 2844

Class

ResourceTestBase
Subclass this for every JSON API resource type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected static 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;
}