Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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