You are here

public function QuizQuestion::save in Quiz 8.6

Same name and namespace in other branches
  1. 8.5 src/Entity/QuizQuestion.php \Drupal\quiz\Entity\QuizQuestion::save()
  2. 6.x src/Entity/QuizQuestion.php \Drupal\quiz\Entity\QuizQuestion::save()

Saves an entity permanently.

When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.

Return value

int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Throws

\Drupal\Core\Entity\EntityStorageException In case of failures an exception is thrown.

Overrides EntityBase::save

1 call to QuizQuestion::save()
MultichoiceQuestion::save in question_types/quiz_multichoice/src/Plugin/quiz/QuizQuestion/MultichoiceQuestion.php
Saves an entity permanently.
1 method overrides QuizQuestion::save()
MultichoiceQuestion::save in question_types/quiz_multichoice/src/Plugin/quiz/QuizQuestion/MultichoiceQuestion.php
Saves an entity permanently.

File

src/Entity/QuizQuestion.php, line 128

Class

QuizQuestion
Defines the Quiz question entity class.

Namespace

Drupal\quiz\Entity

Code

public function save() {

  // Store the calculated max score from the question implementation.
  $this
    ->set('max_score', $this
    ->getMaximumScore());
  parent::save();
}