You are here

protected function RevisionHandler::createRevision in Feeds Paragraphs 8

Creates a revision.

Parameters

Paragraph $paragraph:

2 calls to RevisionHandler::createRevision()
RevisionHandler::checkUpdates in src/RevisionHandler.php
RevisionHandler::removeUnused in src/RevisionHandler.php
Removes any unused entities.

File

src/RevisionHandler.php, line 88

Class

RevisionHandler

Namespace

Drupal\feeds_para_mapper

Code

protected function createRevision(Paragraph $paragraph) {
  $paragraph
    ->setNewRevision(TRUE);
  $paragraph
    ->isDefaultRevision(TRUE);
  try {
    $paragraph
      ->save();
  } catch (EntityStorageException $e) {
    $this->messenger
      ->addError($this
      ->t("Failed to create revision"));
    $this->messenger
      ->addError($e);
  }

  // @see https://www.drupal.org/project/entity_reference_revisions/issues/2984540
  // until this issue is fixed, we need to manually tell the parent entity to use this revision
  $this
    ->updateParentRevision($paragraph);
}