protected function EntityResource::executeQueryInRenderContext in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::executeQueryInRenderContext()
Executes the query in a render context, to catch bubbled cacheability.
@todo Remove this after https://www.drupal.org/project/drupal/issues/3028976 is fixed.
Parameters
\Drupal\Core\Entity\Query\QueryInterface $query: The query to execute to get the return results.
\Drupal\Core\Cache\CacheableMetadata $query_cacheability: The value object to carry the query cacheability.
Return value
int|array Returns an integer for count queries or an array of IDs. The values of the array are always entity IDs. The keys will be revision IDs if the entity supports revision and entity IDs if not.
See also
node_query_node_access_alter()
https://www.drupal.org/project/drupal/issues/2557815
https://www.drupal.org/project/drupal/issues/2794385
1 call to EntityResource::executeQueryInRenderContext()
- EntityResource::getCollection in core/
modules/ jsonapi/ src/ Controller/ EntityResource.php - Gets the collection of entities.
File
- core/
modules/ jsonapi/ src/ Controller/ EntityResource.php, line 486
Class
- EntityResource
- Process all entity requests.
Namespace
Drupal\jsonapi\ControllerCode
protected function executeQueryInRenderContext(QueryInterface $query, CacheableMetadata $query_cacheability) {
$context = new RenderContext();
$results = $this->renderer
->executeInRenderContext($context, function () use ($query) {
return $query
->execute();
});
if (!$context
->isEmpty()) {
$query_cacheability
->addCacheableDependency($context
->pop());
}
return $results;
}