protected function EntityResource::isRelationshipField in JSON:API 8
Checks if is a relationship field.
Parameters
\Drupal\Core\Field\FieldItemListInterface $entity_field: Entity field.
Return value
bool Returns TRUE if entity field is a relationship field with non-internal target resource types, FALSE otherwise.
2 calls to EntityResource::isRelationshipField()
- EntityResource::relationshipAccess in src/
Controller/ EntityResource.php - Check the access to update the entity and the presence of a relationship.
- EntityResource::validateReferencedResource in src/
Controller/ EntityResource.php - Validates that the referenced field points to an enabled resource.
File
- src/
Controller/ EntityResource.php, line 1043
Class
- EntityResource
- Process all entity requests.
Namespace
Drupal\jsonapi\ControllerCode
protected function isRelationshipField(FieldItemListInterface $entity_field) {
$resource_types = $this->resourceType
->getRelatableResourceTypesByField($this->resourceType
->getInternalName($entity_field
->getName()));
return !empty($resource_types) && array_reduce($resource_types, function ($has_external, $resource_type) {
return $has_external ? TRUE : !$resource_type
->isInternal();
}, FALSE);
}