You are here

public function Paragraph::undo in Search and Replace Scanner 8

Undo the replace operation by reverting entities to a previous revision.

Parameters

array $data: An array containing the revision ids needed to undo the previous replace operation.

Overrides Entity::undo

File

src/Plugin/Scanner/Paragraph.php, line 182

Class

Paragraph
Class Paragraph.

Namespace

Drupal\scanner\Plugin\Scanner

Code

public function undo(array $data) {

  // Load the specified paragraph revision.
  $paraRevision = \Drupal::entityTypeManager()
    ->getStorage('paragraph')
    ->loadRevision($data['old_vid']);
  $paraRevision
    ->setNewRevision(TRUE);

  // Set this revision as the current/default revision.
  $paraRevision
    ->isDefaultRevision(TRUE);
  $paraRevision
    ->save();
}