diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index be5239d..4c9f112 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -374,13 +374,8 @@ public function referencedEntities() { * @throws \RuntimeException */ public static function load($id) { - foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $entity_info) { - if ($entity_info->isSubclassOf(get_called_class())) { - return \Drupal::entityManager()->getStorageController($entity_type)->load($id); - } - } - - throw new \RuntimeException(sprintf('The %s class does not correspond to an entity type.', get_called_class())); + $entities = static::loadMultiple(array($id)); + return isset($entities[$id]) ? $entities[$id] : NULL; } /** @@ -395,13 +390,14 @@ public static function load($id) { * @throws \RuntimeException */ public static function loadMultiple(array $ids = NULL) { + $called_class = get_called_class(); foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $entity_info) { - if ($entity_info->isSubclassOf(get_called_class())) { + if ($entity_info->getClass() == $called_class || $entity_info->isSubclassOf($called_class)) { return \Drupal::entityManager()->getStorageController($entity_type)->loadMultiple($ids); } } - throw new \RuntimeException(sprintf('The %s class does not correspond to an entity type.', get_called_class())); + throw new \RuntimeException(sprintf('The %s class does not correspond to an entity type.', $called_class)); } /**