You are here

protected function EntityResource::loadEntitiesWithAccess in JSON:API 8

Same name and namespace in other branches
  1. 8.2 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: Array of entity IDs.

Return value

array An array keyed by entity ID containing the keys:

  • entity: the loaded entity or an access exception.
  • access: the access object.
1 call to EntityResource::loadEntitiesWithAccess()
EntityResource::getCollection in src/Controller/EntityResource.php
Gets the collection of entities.

File

src/Controller/EntityResource.php, line 1065

Class

EntityResource
Process all entity requests.

Namespace

Drupal\jsonapi\Controller

Code

protected function loadEntitiesWithAccess(EntityStorageInterface $storage, array $ids) {
  $output = [];
  foreach ($storage
    ->loadMultiple($ids) as $entity) {
    $output[$entity
      ->id()] = static::getEntityAndAccess($entity);
  }
  return $output;
}