You are here

function shrinktheweb_entity_bundle_delete in ShrinkTheWeb 8

Implements hook_entity_bundle_delete().

File

./shrinktheweb.module, line 384

Code

function shrinktheweb_entity_bundle_delete($entity_type_id, $bundle) {
  if ($entity_type_id == 'node') {
    $shrinktheweb_fields = \Drupal::database()
      ->select('shrinktheweb_fields', 't')
      ->distinct()
      ->fields('t', array(
      'stw_entity_bundle',
    ))
      ->condition('stw_entity_bundle', $bundle)
      ->execute()
      ->fetchCol();
    if (in_array($bundle, $shrinktheweb_fields)) {
      \Drupal::database()
        ->delete('shrinktheweb_fields')
        ->condition('stw_entity_bundle', $bundle, '=')
        ->execute();
    }
  }
}