diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 377ab41..9159224 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -370,8 +370,6 @@ public function referencedEntities() { * * @return static * The entity object or NULL if there is no entity with the given ID. - * - * @throws \RuntimeException */ public static function load($id) { $entities = static::loadMultiple(array($id)); @@ -386,14 +384,24 @@ public static function load($id) { * * @return static[] * An array of entity objects indexed by their IDs. + */ + public static function loadMultiple(array $ids = NULL) { + return \Drupal::entityManager()->getStorageController(static::getEntityTypeFromStaticClass())->loadMultiple($ids); + } + + /** + * Tries to guess an entity type ID based on the class that is called. + * + * @return string + * The entity type ID. * * @throws \RuntimeException */ - public static function loadMultiple(array $ids = NULL) { + protected static function getEntityTypeFromStaticClass() { $called_class = get_called_class(); foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $entity_info) { if ($entity_info->getClass() == $called_class || $entity_info->isSubclassOf($called_class)) { - return \Drupal::entityManager()->getStorageController($entity_type)->loadMultiple($ids); + return $entity_type; } }