function Filter::buildTree
Same name in other branches
- 8.9.x core/modules/jsonapi/src/Query/Filter.php \Drupal\jsonapi\Query\Filter::buildTree()
- 10 core/modules/jsonapi/src/Query/Filter.php \Drupal\jsonapi\Query\Filter::buildTree()
- 11.x core/modules/jsonapi/src/Query/Filter.php \Drupal\jsonapi\Query\Filter::buildTree()
Organizes the flat, normalized filter items into a tree structure.
Parameters
array $root: The root of the tree to build.
array $items: The normalized entity conditions and groups.
Return value
\Drupal\jsonapi\Query\EntityConditionGroup The entity condition group
1 call to Filter::buildTree()
- Filter::buildEntityConditionGroup in core/
modules/ jsonapi/ src/ Query/ Filter.php - Denormalizes the given filter items into a single EntityConditionGroup.
File
-
core/
modules/ jsonapi/ src/ Query/ Filter.php, line 280
Class
- Filter
- Gathers information about the filter parameter.
Namespace
Drupal\jsonapi\QueryCode
protected static function buildTree(array $root, array $items) {
$id = $root['id'];
// Recursively build a tree of denormalized conditions and condition groups.
$members = [];
foreach ($items as $item) {
if ($item[static::MEMBER_KEY] == $id) {
if (isset($item[static::GROUP_KEY])) {
array_push($members, static::buildTree($item, $items));
}
elseif (isset($item[static::CONDITION_KEY])) {
$condition = EntityCondition::createFromQueryParameter($item[static::CONDITION_KEY]);
array_push($members, $condition);
}
}
}
$root[static::GROUP_KEY]['members'] = $members;
// Denormalize the root into a condition group.
return new EntityConditionGroup($root[static::GROUP_KEY]['conjunction'], $root[static::GROUP_KEY]['members']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.