You are here

function wsdata_field_entity_delete in Web Service Data 8

Same name and namespace in other branches
  1. 2.0.x modules/wsdata_field/wsdata_field.module \wsdata_field_entity_delete()

Implements hook_entity_delete().

File

modules/wsdata_field/wsdata_field.module, line 50
Main module file for wsdata_field.

Code

function wsdata_field_entity_delete(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() == 'field_storage_config' && $entity
    ->hasCustomStorage()) {

    // It's a field storage config that has a custom storage.
    $wsfield_config = \Drupal::service('entity_type.manager')
      ->getStorage('wsfield_config')
      ->load($entity
      ->get('field_name'));
    if ($wsfield_config != NULL) {

      // If there is a wsfield config we should delete it.
      $wsfield_config
        ->delete();
    }
  }
}