You are here

function webform_access_field_config_delete in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_access/webform_access.module \webform_access_field_config_delete()

Implements hook_field_config_delete().

File

modules/webform_access/webform_access.module, line 78
Provides webform access controls for webform nodes.

Code

function webform_access_field_config_delete(EntityInterface $entity) {

  /** @var Drupal\field\Entity\FieldConfig $definition */
  if ($entity
    ->getType() === 'webform' && $entity
    ->getEntityTypeId() === 'node') {
    $entity_ids = \Drupal::entityQuery('webform_access_group')
      ->condition('type', $entity
      ->getTargetBundle())
      ->execute();
    if ($entity_ids) {
      \Drupal::database()
        ->delete('webform_access_group_entity')
        ->condition('entity_type', 'node')
        ->condition('entity_id', $entity_ids, 'IN')
        ->condition('field_name', $entity
        ->getName())
        ->execute();
    }
  }
}