protected function QuizQuestionStorage::mapFromStorageRecords in Quiz 6.x
Same name and namespace in other branches
- 8.6 src/Storage/QuizQuestionStorage.php \Drupal\quiz\Storage\QuizQuestionStorage::mapFromStorageRecords()
- 8.5 src/Storage/QuizQuestionStorage.php \Drupal\quiz\Storage\QuizQuestionStorage::mapFromStorageRecords()
When loading from the database, map any object to its respective class.
Overrides SqlContentEntityStorage::mapFromStorageRecords
File
- src/
Storage/ QuizQuestionStorage.php, line 36
Class
Namespace
Drupal\quiz\StorageCode
protected function mapFromStorageRecords(array $records, $load_from_revision = FALSE) {
$pluginManager = Drupal::service('plugin.manager.quiz.question');
$plugins = $pluginManager
->getDefinitions();
$out = [];
foreach ($records as $id => $record) {
$ret = $plugins[$record->type];
if ($ret['class']) {
$this->entityClass = $ret['class'];
}
else {
$this->entityClass = QuizQuestionBroken::class;
}
$entities = parent::mapFromStorageRecords([
$id => $record,
], $load_from_revision);
$out += $entities;
}
return $out;
}