You are here

function webform_invitation_uninstall in Webform Invitation 8

Same name and namespace in other branches
  1. 2.0.x webform_invitation.install \webform_invitation_uninstall()

Implements hook_uninstall().

File

./webform_invitation.install, line 72
Installation functions for the Webform Invitation module.

Code

function webform_invitation_uninstall() {

  /** @var \Drupal\webform\WebformEntityStorageInterface $webform_storage */
  $webform_storage = \Drupal::service('entity_type.manager')
    ->getStorage('webform');

  // Remove Webform Invitation textfields from existing webforms with
  // invitation mode activated.
  $webform_ids = $webform_storage
    ->getQuery()
    ->condition('elements', 'webform_invitation_code', 'CONTAINS')
    ->execute();

  /** @var \Drupal\webform\Entity\Webform $webform */
  foreach ($webform_storage
    ->loadMultiple($webform_ids) as $webform) {
    $webform
      ->deleteElement('webform_invitation_code');
    $webform
      ->save();
  }
}