You are here

protected function QuizStorage::doPostSave in Quiz 6.x

Same name and namespace in other branches
  1. 8.6 src/Storage/QuizStorage.php \Drupal\quiz\Storage\QuizStorage::doPostSave()
  2. 8.5 src/Storage/QuizStorage.php \Drupal\quiz\Storage\QuizStorage::doPostSave()

Performs post save entity processing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The saved entity.

bool $update: Specifies whether the entity is being updated or created.

Overrides ContentEntityStorageBase::doPostSave

File

src/Storage/QuizStorage.php, line 35

Class

QuizStorage

Namespace

Drupal\quiz\Storage

Code

protected function doPostSave(EntityInterface $entity, $update) {

  /* @var $entity \Drupal\quiz\Entity\Quiz */
  if (isset($entity->old_vid)) {

    // Duplicate of quiz.
    $old_vid = $entity->old_vid;
  }
  if (!$entity
    ->isNew() && $entity
    ->isNewRevision()) {

    // New revision of quiz.
    $old_vid = $entity
      ->getLoadedRevisionId();
  }
  if (isset($old_vid)) {
    $original = \Drupal::entityTypeManager()
      ->getStorage('quiz')
      ->loadRevision($old_vid);
    $entity
      ->copyFromRevision($original);
  }
  return parent::doPostSave($entity, $update);
}