You are here

public static function TemporaryQueryGuard::applyAccessControls in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/src/Access/TemporaryQueryGuard.php \Drupal\jsonapi\Access\TemporaryQueryGuard::applyAccessControls()

Applies access controls to an entity query.

Parameters

\Drupal\jsonapi\Query\Filter $filter: The filters applicable to the query.

\Drupal\Core\Entity\Query\QueryInterface $query: The query to which access controls should be applied.

\Drupal\Core\Cache\CacheableMetadata $cacheability: Collects cacheability for the query.

1 call to TemporaryQueryGuard::applyAccessControls()
EntityResource::getCollectionQuery in core/modules/jsonapi/src/Controller/EntityResource.php
Gets a basic query for a collection.

File

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

Class

TemporaryQueryGuard
Adds sufficient access control to collection queries.

Namespace

Drupal\jsonapi\Access

Code

public static function applyAccessControls(Filter $filter, QueryInterface $query, CacheableMetadata $cacheability) {
  assert(static::$fieldManager !== NULL);
  assert(static::$moduleHandler !== NULL);
  $filtered_fields = static::collectFilteredFields($filter
    ->root());
  $field_specifiers = array_map(function ($field) {
    return explode('.', $field);
  }, $filtered_fields);
  static::secureQuery($query, $query
    ->getEntityTypeId(), static::buildTree($field_specifiers), $cacheability);
}