Skip to content
Snippets Groups Projects
Unverified Commit df5f3e75 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3039730 by ndobromirov, Wim Leers, e0ipso, l0ke, webchick, xjm: Include...

Issue #3039730 by ndobromirov, Wim Leers, e0ipso, l0ke, webchick, xjm: Include paths are resolved for every resource in a resource collection, instead of once per unique resource type

(cherry picked from commit c1b9f954)
parent 25a72bbb
Branches
Tags
No related merge requests found
......@@ -176,11 +176,17 @@ protected static function toIncludeTree(ResourceObjectData $data, $include_param
$exploded_paths = array_map(function ($include_path) {
return array_map('trim', explode('.', $include_path));
}, $include_paths);
$resolved_paths = [];
$resolved_paths_per_resource_type = [];
/* @var \Drupal\jsonapi\JsonApiResource\ResourceIdentifierInterface $resource_object */
foreach ($data as $resource_object) {
$resolved_paths = array_merge($resolved_paths, static::resolveInternalIncludePaths($resource_object->getResourceType(), $exploded_paths));
$resource_type = $resource_object->getResourceType();
$resource_type_name = $resource_type->getTypeName();
if (isset($resolved_paths_per_resource_type[$resource_type_name])) {
continue;
}
$resolved_paths_per_resource_type[$resource_type_name] = static::resolveInternalIncludePaths($resource_type, $exploded_paths);
}
$resolved_paths = array_reduce($resolved_paths_per_resource_type, 'array_merge', []);
return static::buildTree($resolved_paths);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment