You are here

function entity_load_unchanged in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/includes/entity.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.


\Drupal::entityManager()->getStorage($entity_type)->loadUnchanged($id).

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

as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use the entity storage's loadUnchanged() method to load an unchanged entity:

See also

\Drupal\Core\Entity\EntityManagerInterface::getStorage()

\Drupal\Core\Entity\EntityStorageInterface::loadUnchanged()

2 calls to entity_load_unchanged()
content_translation_entity_presave in core/modules/content_translation/content_translation.module
Implements hook_entity_presave().
ImageAdminStylesTest::testStyle in core/modules/image/src/Tests/ImageAdminStylesTest.php
General test to add a style, add/remove/edit effects to it, then delete it.

File

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

Code

function entity_load_unchanged($entity_type, $id) {
  return \Drupal::entityManager()
    ->getStorage($entity_type)
    ->loadUnchanged($id);
}