function AliasingResourceTypeRepository::getFields

Same name in other branches
  1. 9 core/modules/jsonapi/tests/modules/jsonapi_test_field_aliasing/src/ResourceType/AliasingResourceTypeRepository.php \Drupal\jsonapi_test_field_aliasing\ResourceType\AliasingResourceTypeRepository::getFields()
  2. 10 core/modules/jsonapi/tests/modules/jsonapi_test_field_aliasing/src/ResourceType/AliasingResourceTypeRepository.php \Drupal\jsonapi_test_field_aliasing\ResourceType\AliasingResourceTypeRepository::getFields()
  3. 11.x core/modules/jsonapi/tests/modules/jsonapi_test_field_aliasing/src/ResourceType/AliasingResourceTypeRepository.php \Drupal\jsonapi_test_field_aliasing\ResourceType\AliasingResourceTypeRepository::getFields()

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\ResourceType

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.