function entity_load_multiple

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.

Parameters

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.

Return value

array An array of entity objects indexed by their ids.

See also

\Drupal\Core\Entity\EntityManager

Drupal\Core\Entity\EntityStorageControllerInterface

Drupal\Core\Entity\DatabaseStorageController

Drupal\Core\Entity\Query\QueryInterface

71 calls to entity_load_multiple()
aggregator_load_feed_items in drupal/core/modules/aggregator/aggregator.pages.inc
Loads and optionally filters feed items.
AutocompleteWidgetBase::getLabels in drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php
Gets the entity labels.
BlockListController::submitForm in drupal/core/modules/block/lib/Drupal/block/BlockListController.php
Implements \Drupal\Core\Form\FormInterface::submitForm().
block_language_delete in drupal/core/modules/block/block.module
Implements hook_language_delete().
block_menu_delete in drupal/core/modules/block/block.module
Implements hook_menu_delete().

... See full list

File

drupal/core/includes/entity.inc, line 273
Entity API for handling entities like nodes or users.

Code

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);
}