protected function QuizResultAnswerStorage::mapFromStorageRecords in Quiz 6.x
Same name and namespace in other branches
- 8.6 src/Storage/QuizResultAnswerStorage.php \Drupal\quiz\Storage\QuizResultAnswerStorage::mapFromStorageRecords()
- 8.5 src/Storage/QuizResultAnswerStorage.php \Drupal\quiz\Storage\QuizResultAnswerStorage::mapFromStorageRecords()
When loading from the database, map any object to its respective class.
Overrides SqlContentEntityStorage::mapFromStorageRecords
File
- src/
Storage/ QuizResultAnswerStorage.php, line 35
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['handlers']['response']) {
$this->entityClass = $ret['handlers']['response'];
}
else {
$this->entityClass = 'Drupal\\quiz\\Entity\\QuizResultAnswerBroken';
}
$entities = parent::mapFromStorageRecords([
$id => $record,
], $load_from_revision);
$out += $entities;
}
return $out;
}