function ResourceTypeRepository::isReferenceFieldDefinition
Same name in other branches
- 9 core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::isReferenceFieldDefinition()
- 10 core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::isReferenceFieldDefinition()
- 11.x core/modules/jsonapi/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.
2 calls to ResourceTypeRepository::isReferenceFieldDefinition()
- ResourceTypeRepository::calculateRelatableResourceTypes in core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php - Calculates relatable JSON:API resource types for a given resource type.
- ResourceTypeRepository::getFields in core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php - Gets the field mapping for the given field names and entity type + bundle.
File
-
core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php, line 488
Class
- ResourceTypeRepository
- Provides a repository of all JSON:API resource types.
Namespace
Drupal\jsonapi\ResourceTypeCode
protected function isReferenceFieldDefinition(FieldDefinitionInterface $field_definition) {
static $field_type_is_reference = [];
if (isset($field_type_is_reference[$field_definition->getType()])) {
return $field_type_is_reference[$field_definition->getType()];
}
/* @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 $field_type_is_reference[$field_definition->getType()] = $property_definition instanceof DataReferenceTargetDefinition;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.