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

8.0.x
catch 2013-03-06 21:53:22 +00:00
parent a3064d2020
commit e5de05353f
4 changed files with 35 additions and 4 deletions

View File

@ -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);
}
/**

View File

@ -142,6 +142,15 @@ class ConfigStorageController implements EntityStorageControllerInterface {
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().
*/

View File

@ -235,6 +235,15 @@ class DatabaseStorageController implements EntityStorageControllerInterface {
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().
*/

View File

@ -40,6 +40,20 @@ interface EntityStorageControllerInterface {
*/
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.
*