You are here

protected function QuizResultAnswerStorage::doCreate in Quiz 8.5

Same name and namespace in other branches
  1. 8.6 src/Storage/QuizResultAnswerStorage.php \Drupal\quiz\Storage\QuizResultAnswerStorage::doCreate()
  2. 6.x src/Storage/QuizResultAnswerStorage.php \Drupal\quiz\Storage\QuizResultAnswerStorage::doCreate()

When creating a new entity, map any object to its respective class.

Overrides ContentEntityStorageBase::doCreate

File

src/Storage/QuizResultAnswerStorage.php, line 15

Class

QuizResultAnswerStorage

Namespace

Drupal\quiz\Storage

Code

protected function doCreate(array $values) {
  $pluginManager = Drupal::service('plugin.manager.quiz.question');
  $plugins = $pluginManager
    ->getDefinitions();
  $ret = $plugins[$values['type']];
  if ($ret['handlers']['response']) {
    $this->entityClass = $ret['handlers']['response'];
  }
  else {
    $this->entityClass = 'Drupal\\quiz\\Entity\\QuizResultAnswerBroken';
  }
  return parent::doCreate($values);
}