You are here

protected function ComplexDataDefinitionNormalizer::isReferenceField in JSON:API Schema 8

Determine if the current field is a reference field.

Parameters

\Drupal\Core\TypedData\ComplexDataDefinitionInterface $entity: The complex data definition to be checked.

array $context: The current serializer context.

Return value

bool TRUE if it is a reference, FALSE otherwise.

File

src/Normalizer/ComplexDataDefinitionNormalizer.php, line 65

Class

ComplexDataDefinitionNormalizer
Normalizer for ComplexDataDefinitionInterface.

Namespace

Drupal\jsonapi_schema\Normalizer

Code

protected function isReferenceField(ComplexDataDefinitionInterface $entity, array $context = NULL) {
  $main = $entity
    ->getPropertyDefinition($entity
    ->getMainPropertyName());

  // @todo use an interface or API call instead of an object check.
  return $main instanceof DataReferenceTargetDefinition;
}