Skip to content
Snippets Groups Projects
Unverified Commit 8ed64472 authored by Mateu Aguiló Bosch's avatar Mateu Aguiló Bosch Committed by Mateu Aguiló Bosch
Browse files

Issue #2986408 by e0ipso, Wim Leers: Use aliasing capabilities provided by JSON API 2.x

parent ac251c05
Branches
Tags 8.x-3.0-rc2
No related merge requests found
......@@ -253,15 +253,21 @@ class ConfigurableResourceTypeRepository extends ResourceTypeRepository {
if ($resource_config instanceof NullJsonapiResourceConfig) {
return [];
}
$entity_type = $resource_config->getEntityType();
$bundle = $resource_config->bundle();
list($entity_type_id, $bundle) = explode('--', $resource_config->getOriginalId());
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
$field_names = $this->getAllFieldNames($entity_type, $bundle);
// Use the base class to fetch the non-configurable field mappings.
$mappings = static::getFieldMapping($field_names, $entity_type, $bundle);
// Make sure to respect the overrides coming from JSON:API.
array_merge($resource_config->getFieldMapping(), $mappings);
return $mappings;
$mappings = $resource_config->getFieldMapping();
// Ignore all the fields that don't have aliases.
$mappings = array_filter($mappings, function ($field_info) {
return $field_info !== TRUE;
});
// Make sure to respect the overrides coming from JSON:API if there is no
// input in JSON:API Extras.
return array_merge(
static::getFieldMapping($field_names, $entity_type, $bundle),
$mappings
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment