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 'controller_class' 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

30 calls to entity_load_multiple()
BreakpointCRUDTest::testBreakpointCRUD in drupal/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php
Test CRUD operations for breakpoints.
breakpoint_group_select_options in drupal/core/modules/breakpoint/breakpoint.module
Load all breakpoint groups as select options.
breakpoint_select_options in drupal/core/modules/breakpoint/breakpoint.module
Load all breakpoints as select options.
BulkDeleteTest::setUp in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Set the default field storage backend for fields created during tests.
comment_load_multiple in drupal/core/modules/comment/comment.module
Loads comment entities from the database.

... See full list

File

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

Code

function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
  if ($reset) {
    entity_get_controller($entity_type)
      ->resetCache();
  }
  return entity_get_controller($entity_type)
    ->load($ids);
}