if ($entity_type instanceof ConfigEntityTypeInterface
) { // The '_core' key is reserved by Drupal core to handle complex edge cases
// correctly. Data in the '_core' key is irrelevant to clients reading
// configuration, and is not allowed to be set by clients writing
// configuration: it is for Drupal core only, and managed by Drupal core.
// @see https://www.drupal.org/node/2653358
$fields['_core'
] =
new ResourceTypeAttribute('_core', NULL, FALSE
);
} $is_fieldable =
$entity_type->
entityClassImplements(FieldableEntityInterface::
class);
if ($is_fieldable) { $field_definitions =
$this->entityFieldManager->
getFieldDefinitions($entity_type->
id(),
$bundle);
} // For all other fields, use their internal field name also as their public
// field name. Unless they're called "id" or "type": those names are
// reserved by the JSON:API spec.
// @see http://jsonapi.org/format/#document-resource-object-fields
$reserved_field_names =
['id', 'type'
];
foreach (array_diff($field_names,
array_keys($fields)) as $field_name) { $alias =
$field_name;
// Alias the fields reserved by the JSON:API spec with `{entity_type}_`.
if (in_array($field_name,
$reserved_field_names, TRUE
)) {