protected static function TemporaryQueryGuard::buildTree in JSON:API 8
Same name and namespace in other branches
- 8.2 src/Access/TemporaryQueryGuard.php \Drupal\jsonapi\Access\TemporaryQueryGuard::buildTree()
Copied from \Drupal\jsonapi\IncludeResolver.
See also
\Drupal\jsonapi\IncludeResolver::buildTree()
1 call to TemporaryQueryGuard::buildTree()
- TemporaryQueryGuard::applyAccessControls in src/
Access/ TemporaryQueryGuard.php - Applies access controls to an entity query.
File
- src/
Access/ TemporaryQueryGuard.php, line 603
Class
- TemporaryQueryGuard
- Adds sufficient access control to collection queries.
Namespace
Drupal\jsonapi\AccessCode
protected static function buildTree(array $paths) {
$merged = [];
foreach ($paths as $parts) {
// This complex expression is needed to handle the string, "0", which
// would be evaluated as FALSE.
if (!is_null($field_name = array_shift($parts))) {
$previous = isset($merged[$field_name]) ? $merged[$field_name] : [];
$merged[$field_name] = array_merge($previous, [
$parts,
]);
}
}
return !empty($merged) ? array_map([
static::class,
__FUNCTION__,
], $merged) : $merged;
}