protected function EntityResource::loadEntitiesWithAccess in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::loadEntitiesWithAccess()
Build a collection of the entities to respond with and access objects.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage to load the entities from.
int[] $ids: An array of entity IDs, keyed by revision ID if the entity type is revisionable.
bool $load_latest_revisions: Whether to load the latest revisions instead of the defaults.
Return value
array An array of loaded entities and/or an access exceptions.
1 call to EntityResource::loadEntitiesWithAccess()
- EntityResource::getCollection in core/
modules/ jsonapi/ src/ Controller/ EntityResource.php - Gets the collection of entities.
File
- core/
modules/ jsonapi/ src/ Controller/ EntityResource.php, line 1167
Class
- EntityResource
- Process all entity requests.
Namespace
Drupal\jsonapi\ControllerCode
protected function loadEntitiesWithAccess(EntityStorageInterface $storage, array $ids, $load_latest_revisions) {
$output = [];
if ($load_latest_revisions) {
assert($storage instanceof RevisionableStorageInterface);
$entities = $storage
->loadMultipleRevisions(array_keys($ids));
}
else {
$entities = $storage
->loadMultiple($ids);
}
foreach ($entities as $entity) {
$output[$entity
->id()] = $this->entityAccessChecker
->getAccessCheckedResourceObject($entity);
}
return array_values($output);
}