function TemporaryQueryGuard::buildTree

Same name in other branches
  1. 9 core/modules/jsonapi/src/Access/TemporaryQueryGuard.php \Drupal\jsonapi\Access\TemporaryQueryGuard::buildTree()
  2. 8.9.x core/modules/jsonapi/src/Access/TemporaryQueryGuard.php \Drupal\jsonapi\Access\TemporaryQueryGuard::buildTree()
  3. 11.x core/modules/jsonapi/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 core/modules/jsonapi/src/Access/TemporaryQueryGuard.php
Applies access controls to an entity query.

File

core/modules/jsonapi/src/Access/TemporaryQueryGuard.php, line 589

Class

TemporaryQueryGuard
Adds sufficient access control to collection queries.

Namespace

Drupal\jsonapi\Access

Code

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 = $merged[$field_name] ?? [];
            $merged[$field_name] = array_merge($previous, [
                $parts,
            ]);
        }
    }
    return !empty($merged) ? array_map([
        static::class,
        __FUNCTION__,
    ], $merged) : $merged;
}

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