protected static function ResourceObject::getLabelFieldName in JSON:API 8.2
Determines the entity type's (internal) label field name.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity from which fields should be extracted.
Return value
string The label field name.
1 call to ResourceObject::getLabelFieldName()
- LabelOnlyResourceObject::extractFieldsFromEntity in src/
JsonApiResource/ LabelOnlyResourceObject.php - Extracts the entity's fields.
File
- src/
JsonApiResource/ ResourceObject.php, line 309
Class
- ResourceObject
- Represents a JSON:API resource object.
Namespace
Drupal\jsonapi\JsonApiResourceCode
protected static function getLabelFieldName(EntityInterface $entity) {
$label_field_name = $entity
->getEntityType()
->getKey('label');
// @todo Remove this work-around after https://www.drupal.org/project/drupal/issues/2450793 lands.
if ($entity
->getEntityTypeId() === 'user') {
$label_field_name = 'name';
}
return $label_field_name;
}