You are here

public function EntityStorageBase::load in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::load()
  2. 10 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::load()

Loads one entity.

Parameters

mixed $id: The ID of the entity to load.

Return value

\Drupal\Core\Entity\EntityInterface|null An entity object. NULL if no matching entity is found.

Overrides EntityStorageInterface::load

10 calls to EntityStorageBase::load()
ConfigEntityStorage::importDelete in core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
Delete entities upon synchronizing configuration changes.
ConfigEntityStorage::importUpdate in core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
Updates entities upon synchronizing configuration changes.
ContentEntityStorageBase::createRevision in core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
Creates a new revision starting off from the specified entity object.
ContentEntityStorageBase::loadUnchanged in core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
Loads an unchanged entity from the database.
EntityStorageBase::loadUnchanged in core/lib/Drupal/Core/Entity/EntityStorageBase.php
Loads an unchanged entity from the database.

... See full list

2 methods override EntityStorageBase::load()
ContentEntityNullStorage::load in core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php
Loads one entity.
EntityTestNoLoadStorage::load in core/modules/system/tests/modules/entity_test/src/EntityTestNoLoadStorage.php
Loads one entity.

File

core/lib/Drupal/Core/Entity/EntityStorageBase.php, line 243

Class

EntityStorageBase
A base entity storage class.

Namespace

Drupal\Core\Entity

Code

public function load($id) {
  assert(!is_null($id), sprintf('Cannot load the "%s" entity with NULL ID.', $this->entityTypeId));
  $entities = $this
    ->loadMultiple([
    $id,
  ]);
  return isset($entities[$id]) ? $entities[$id] : NULL;
}