function ResourceTypeRepository::getFieldMapping
Gets the field mapping for the given field names and entity type + bundle.
Parameters
string[] $field_names: All field names on a bundle of the given entity type.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type for which to get the field mapping.
string $bundle: The bundle to assess.
Return value
array An array with:
- keys are (real/internal) field names
- values are either FALSE (indicating the field is not exposed despite not being internal), TRUE (indicating the field should be exposed under its internal name) or a string (indicating the field should not be exposed using its internal name, but the name specified in the string)
Deprecated
in drupal:8.8.0 and is removed from drupal:9.0.0. Use self::getFields() instead.
See also
https://www.drupal.org/project/drupal/issues/3014277
File
-
core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php, line 315
Class
- ResourceTypeRepository
- Provides a repository of all JSON:API resource types.
Namespace
Drupal\jsonapi\ResourceTypeCode
protected function getFieldMapping(array $field_names, EntityTypeInterface $entity_type, $bundle) {
$class_name = self::class;
@trigger_error("{$class_name}::getFieldMapping() is deprecated in Drupal 8.8.0 and will not be allowed in Drupal 9.0.0. Use {$class_name}::getFields() instead. See https://www.drupal.org/project/drupal/issues/3014277.", E_USER_DEPRECATED);
$fields = $this->getFields($field_names, $entity_type, $bundle);
return array_map(function (ResourceTypeField $field) {
if ($field->isFieldEnabled()) {
return $field->getInternalName() !== $field->getPublicName() ? $field->getPublicName() : TRUE;
}
return FALSE;
}, $fields);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.