You are here

function entity_load_unchanged in Drupal 8

Same name and namespace in other branches
  1. 7 includes/common.inc \entity_load_unchanged()

Loads the unchanged, i.e. not modified, entity from the database.

Unlike entity_load() this function ensures the entity is directly loaded from the database, thus bypassing any static cache. In particular, this function is useful to determine changes by comparing the entity being saved to the stored entity.

Parameters

$entity_type: The entity type to load, e.g. node or user.

$id: The ID of the entity to load.

Return value

\Drupal\Core\Entity\EntityInterface|null The unchanged entity, or FALSE if the entity cannot be loaded.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use the entity type storage's loadUnchanged() method.

See also

https://www.drupal.org/node/1935744

1 call to entity_load_unchanged()
EntityLegacyTest::testEntityLegacyCode in core/tests/Drupal/KernelTests/Core/Entity/EntityLegacyTest.php
@expectedDeprecation entity_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use the entity type storage's loadMultiple() method. See https://www.drupal.org/node/2266845 @expectedDeprecation entity_load() is…

File

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

Code

function entity_load_unchanged($entity_type, $id) {
  @trigger_error('entity_load_unchanged() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use the entity type storage\'s loadUnchanged() method. See https://www.drupal.org/node/1935744', E_USER_DEPRECATED);
  return \Drupal::entityManager()
    ->getStorage($entity_type)
    ->loadUnchanged($id);
}