protected function ContentEntityStorageBase::preLoad in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::preLoad()
- 9 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::preLoad()
Gathers entities from a 'preload' step.
Parameters
array|null &$ids: If not empty, return entities that match these IDs. IDs that were found will be removed from the list.
Return value
\Drupal\Core\Entity\EntityInterface[] Associative array of entities, keyed by the entity ID.
Overrides EntityStorageBase::preLoad
1 call to ContentEntityStorageBase::preLoad()
- ContentEntityStorageBase::loadUnchanged in core/
lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php - Loads an unchanged entity from the database.
File
- core/
lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php, line 603
Class
- ContentEntityStorageBase
- Base class for content entity storage handlers.
Namespace
Drupal\Core\EntityCode
protected function preLoad(array &$ids = NULL) {
$entities = [];
// Call hook_entity_preload().
$preload_ids = $ids ?: [];
$preload_entities = $this
->moduleHandler()
->invokeAll('entity_preload', [
$preload_ids,
$this->entityTypeId,
]);
foreach ((array) $preload_entities as $entity) {
$entities[$entity
->id()] = $entity;
}
if ($entities) {
// If any entities were pre-loaded, remove them from the IDs still to
// load.
if ($ids !== NULL) {
$ids = array_keys(array_diff_key(array_flip($ids), $entities));
}
else {
$result = $this
->getQuery()
->accessCheck(FALSE)
->condition($this->entityType
->getKey('id'), array_keys($entities), 'NOT IN')
->execute();
$ids = array_values($result);
}
}
return $entities;
}