Loading core/lib/Drupal/Core/Entity/EntityStorageBase.php +5 −1 Original line number Diff line number Diff line Loading @@ -451,7 +451,11 @@ protected function mapFromStorageRecords(array $records) { $entity_class = $this->getEntityClass(); /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = new $entity_class($record, $this->entityTypeId); $entities[$entity->id()] = $entity; $entity_id = $entity->id(); if ($entity_id === NULL) { throw new EntityMalformedException('The entity does not have an ID.'); } $entities[$entity_id] = $entity; } return $entities; } Loading core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +13 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,19 @@ public function doLoadMultiple(?array $ids = NULL) { return $this->mapFromStorageRecords($entities); } /** * {@inheritdoc} */ protected function mapFromStorageRecords(array $records) { $entities = []; foreach ($records as $record) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = $this->doCreate($record); $entities[$entity->id()] = $entity; } return $entities; } /** * {@inheritdoc} */ Loading core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php +7 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,13 @@ public function testCRUD(): void { // Verify that originalID points to new ID directly after renaming. $this->assertSame($new_id, $entity_test->id()); } // Test loading multiple entities. There should be an entity keyed by the ID // we just created. $entities = $storage->loadMultiple(); $this->assertCount(3, $entities); $this->assertArrayHasKey($entity_test->id(), $entities); $this->assertSame($entity_test->uuid(), $entities[$entity_test->id()]->uuid()); } /** Loading Loading
core/lib/Drupal/Core/Entity/EntityStorageBase.php +5 −1 Original line number Diff line number Diff line Loading @@ -451,7 +451,11 @@ protected function mapFromStorageRecords(array $records) { $entity_class = $this->getEntityClass(); /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = new $entity_class($record, $this->entityTypeId); $entities[$entity->id()] = $entity; $entity_id = $entity->id(); if ($entity_id === NULL) { throw new EntityMalformedException('The entity does not have an ID.'); } $entities[$entity_id] = $entity; } return $entities; } Loading
core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +13 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,19 @@ public function doLoadMultiple(?array $ids = NULL) { return $this->mapFromStorageRecords($entities); } /** * {@inheritdoc} */ protected function mapFromStorageRecords(array $records) { $entities = []; foreach ($records as $record) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = $this->doCreate($record); $entities[$entity->id()] = $entity; } return $entities; } /** * {@inheritdoc} */ Loading
core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php +7 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,13 @@ public function testCRUD(): void { // Verify that originalID points to new ID directly after renaming. $this->assertSame($new_id, $entity_test->id()); } // Test loading multiple entities. There should be an entity keyed by the ID // we just created. $entities = $storage->loadMultiple(); $this->assertCount(3, $entities); $this->assertArrayHasKey($entity_test->id(), $entities); $this->assertSame($entity_test->uuid(), $entities[$entity_test->id()]->uuid()); } /** Loading