Problem/Motivation
When presenting an entity for interaction by a content author, many factors are considered:
- What is the entity type?
- What is the entity ID?
- What is the revision?
- What is the language?
- Other things?
Some of these things are codified in places like \Drupal\Core\ParamConverter\EntityConverter
But that is not an API that is reusable.
Additionally, the current best practice for retrieving an entity is:
$entity = $this->entityTypeManager->getStorage($entity_type_id)->load($entity_id);
Yet this bypasses all access, revision checking, translation handling, etc.
Core provides a service for loading entities: \Drupal\Core\Entity\EntityRepository
But it only provides other helper methods for edge cases, not the 80% case.
Proposed resolution
Expand \Drupal\Core\Entity\EntityRepository to include methods for:
- retrieving the raw entity (equivalent of getStorage()->load())
- retrieving a version of the entity suitable for editing (latest revision? correct language?)
Switch the static Entity::load() to use the correct one instead of it manually introspecting the storage.