By plach on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
The EntityStorageControllerInterface::loadUnchanged() has been added as the OO counterpart of entity_load_unchanged(), which now just forwards the call to the storage controller. As before the returned value is the entity as currently stored.
Before:
<?php
class ClassDealingWithEntities {
public function doStuff(EntityInterface $entity) {
// Bad, not properly unit-testable.
$unchanged_entity = entity_load_unchanged($entity->id());
// ...
}
}
?>
After:
<?php
class ClassDealingWithEntities {
protected $manager;
public function __construct(EntityManagerInterface $manager) {
$this->manager = $manager;
}
public function doStuff(EntityInterface $entity) {
$unchanged_entity = $this->manager
->getStorageController($entity->entityType())
->loadUnchanged($entity->id());
// ...
}
}
?>
Impacts:
Module developers