Implements Drupal\Core\Entity\EntityStorageControllerInterface::load().
Overrides EntityStorageControllerInterface::load
public function load(array $ids = NULL) {
$entities = array();
// Create a new variable which is either a prepared version of the $ids
// array for later comparison with the entity cache, or FALSE if no $ids
// were passed.
$passed_ids = !empty($ids) ? array_flip($ids) : FALSE;
// Load any remaining entities. This is the case if $ids is set to NULL (so
// we load all entities).
if ($ids === NULL || $ids) {
$queried_entities = $this
->buildQuery($ids);
}
// Pass all entities loaded from the database through $this->attachLoad(),
// which calls the
// entity type specific load callback, for example hook_node_type_load().
if (!empty($queried_entities)) {
$this
->attachLoad($queried_entities);
$entities += $queried_entities;
}
// Ensure that the returned array is ordered the same as the original
// $ids array if this was passed in and remove any invalid ids.
if ($passed_ids) {
// Remove any invalid ids from the array.
$passed_ids = array_intersect_key($passed_ids, $entities);
foreach ($entities as $entity) {
$passed_ids[$entity->{$this->idKey}] = $entity;
}
$entities = $passed_ids;
}
return $entities;
}