Commit e5de0535 authored by catch's avatar catch

Issue #1919322 by plach: Entity_load_unchanged() should be part of the storage controller.

parent a3064d20
......@@ -297,10 +297,9 @@ function entity_load_multiple_by_properties($entity_type, array $values) {
* The unchanged entity, or FALSE if the entity cannot be loaded.
*/
function entity_load_unchanged($entity_type, $id) {
$controller = drupal_container()->get('plugin.manager.entity')->getStorageController($entity_type);
$controller->resetCache(array($id));
$result = $controller->load(array($id));
return reset($result);
return drupal_container()->get('plugin.manager.entity')
->getStorageController($entity_type)
->loadUnchanged($id);
}
/**
......
......@@ -142,6 +142,15 @@ public function load(array $ids = NULL) {
return $entities;
}
/**
* Implements \Drupal\Core\Entity\EntityStorageControllerInterface::loadUnchanged()
*/
public function loadUnchanged($id) {
$this->resetCache(array($id));
$result = $this->load(array($id));
return reset($result);
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::loadRevision().
*/
......
......@@ -235,6 +235,15 @@ public function load(array $ids = NULL) {
return $entities;
}
/**
* Implements \Drupal\Core\Entity\EntityStorageControllerInterface::loadUnchanged()
*/
public function loadUnchanged($id) {
$this->resetCache(array($id));
$result = $this->load(array($id));
return reset($result);
}
/**
* Implements \Drupal\Core\Entity\EntityStorageControllerInterface::loadRevision().
*/
......
......@@ -40,6 +40,20 @@ public function resetCache(array $ids = NULL);
*/
public function load(array $ids = NULL);
/**
* Loads an unchanged entity from the database.
*
* @param mixed $id
* The ID of the entity to load.
*
* @return \Drupal\Core\Entity\EntityInterface
* The unchanged entity, or FALSE if the entity cannot be loaded.
*
* @todo Remove this method once we have a reliable way to retrieve the
* unchanged entity from the entity object.
*/
public function loadUnchanged($id);
/**
* Load a specific entity revision.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment