protected function AliasingResourceTypeRepository::getFields in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/tests/modules/jsonapi_test_field_aliasing/src/ResourceType/AliasingResourceTypeRepository.php \Drupal\jsonapi_test_field_aliasing\ResourceType\AliasingResourceTypeRepository::getFields()
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
\Drupal\jsonapi\ResourceType\ResourceTypeField[] An array of JSON:API resource type fields keyed by internal field names.
Overrides ResourceTypeRepository::getFields
File
- core/
modules/ jsonapi/ tests/ modules/ jsonapi_test_field_aliasing/ src/ ResourceType/ AliasingResourceTypeRepository.php, line 16
Class
- AliasingResourceTypeRepository
- Provides a repository of JSON:API resource types with aliasable field names.
Namespace
Drupal\jsonapi_test_field_aliasing\ResourceTypeCode
protected function getFields(array $field_names, EntityTypeInterface $entity_type, $bundle) {
$fields = parent::getFields($field_names, $entity_type, $bundle);
foreach ($fields as $field_name => $field) {
if (strpos($field_name, 'field_test_alias_') === 0) {
$fields[$field_name] = $fields[$field_name]
->withPublicName('field_test_alias');
}
}
return $fields;
}