/**
  * Prepares a revision to be reverted.
  *
  * @param \Drupal\support_ticket\SupportTicketInterface $revision
  *   The revision to be reverted.
  *
  * @return \Drupal\support_ticket\SupportTicketInterface
  *   The prepared revision ready to be stored.
  */
 protected function prepareRevertedRevision(SupportTicketInterface $revision)
 {
     /** @var \Drupal\support_ticket\SupportTicketInterface $default_revision */
     $default_revision = $this->supportTicketStorage->load($revision->id());
     // If the entity is translated, make sure only translations affected by the
     // specified revision are reverted.
     $languages = $default_revision->getTranslationLanguages();
     if (count($languages) > 1) {
         foreach ($languages as $langcode => $language) {
             if ($revision->hasTranslation($langcode) && !$revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
                 $revision_translation = $revision->getTranslation($langcode);
                 $default_translation = $default_revision->getTranslation($langcode);
                 foreach ($default_revision->getFieldDefinitions() as $field_name => $definition) {
                     if ($definition->isTranslatable()) {
                         $revision_translation->set($field_name, $default_translation->get($field_name)->getValue());
                     }
                 }
             }
         }
     }
     $revision->setNewRevision();
     $revision->isDefaultRevision(TRUE);
     return $revision;
 }