You are here

public static function PrepareUninstallForm::removeFields in Simplenews 8.2

Same name and namespace in other branches
  1. 8 src/Form/PrepareUninstallForm.php \Drupal\simplenews\Form\PrepareUninstallForm::removeFields()
  2. 3.x src/Form/PrepareUninstallForm.php \Drupal\simplenews\Form\PrepareUninstallForm::removeFields()

Removes Simplenews fields.

File

src/Form/PrepareUninstallForm.php, line 77

Class

PrepareUninstallForm
Removes fields and data used by Simplenews.

Namespace

Drupal\simplenews\Form

Code

public static function removeFields() {
  $field_config_storage = \Drupal::entityTypeManager()
    ->getStorage('field_config');
  $simplenews_fields_ids = $field_config_storage
    ->getQuery()
    ->condition('field_type', 'simplenews_', 'STARTS_WITH')
    ->execute();
  $simplenews_fields = $field_config_storage
    ->loadMultiple($simplenews_fields_ids);
  $field_config_storage
    ->delete($simplenews_fields);
}