Loads multiple entities from the database.
This function should be used whenever you need to load more than one entity from the database. The entities are loaded into memory and will not require database access if loaded again during the same page request.
The actual loading is done through a class that has to implement the Drupal\Core\Entity\EntityStorageControllerInterface interface. By default, Drupal\Core\Entity\DatabaseStorageController is used. Entity types can specify that a different class should be used by setting the "controllers['storage']" key in the entity plugin annotation. These classes can either implement the Drupal\Core\Entity\EntityStorageControllerInterface interface, or, most commonly, extend the Drupal\Core\Entity\DatabaseStorageController class. See Drupal\node\Plugin\Core\Entity\Node and Drupal\node\NodeStorageController for an example.
string $entity_type: The entity type to load, e.g. node or user.
array $ids: (optional) An array of entity IDs. If omitted, all entities are loaded.
bool $reset: Whether to reset the internal cache for the requested entity type.
array An array of entity objects indexed by their ids.
\Drupal\Core\Entity\EntityManager
Drupal\Core\Entity\EntityStorageControllerInterface
Drupal\Core\Entity\DatabaseStorageController
Drupal\Core\Entity\Query\QueryInterface
function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
$controller = Drupal::entityManager()
->getStorageController($entity_type);
if ($reset) {
$controller
->resetCache();
}
return $controller
->load($ids);
}