You are here

public function WebformRevisionsConfigTrait::deleteRelatedContentEntities in Config Entity Revisions 8

Same name and namespace in other branches
  1. 1.x modules/webform_revisions/src/WebformRevisionsConfigTrait.php \Drupal\webform_revisions\WebformRevisionsConfigTrait::deleteRelatedContentEntities()

Delete submissions related to a revision.

File

modules/webform_revisions/src/WebformRevisionsConfigTrait.php, line 42

Class

WebformRevisionsConfigTrait

Namespace

Drupal\webform_revisions

Code

public function deleteRelatedContentEntities($rid) {
  $sids = \Drupal::database()
    ->query("SELECT sid FROM {webform_submission} WHERE webform_revision = :rid", [
    ':rid' => $rid,
  ])
    ->fetchCol();
  $storage = \Drupal::entityTypeManager()
    ->getStorage('webform_submission');
  $submissions = $storage
    ->loadMultiple($sids);
  $storage
    ->delete($submissions);
}