function FieldConfig::postDelete
Overrides EntityBase::postDelete
File
- 
              core/
modules/ field/ src/ Entity/ FieldConfig.php, line 224  
Class
- FieldConfig
 - Defines the Field entity.
 
Namespace
Drupal\field\EntityCode
public static function postDelete(EntityStorageInterface $storage, array $fields) {
  // Clear the cache upfront, to refresh the results of getBundles().
  \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
  // Notify the entity storage.
  foreach ($fields as $field) {
    if (!$field->deleted) {
      \Drupal::service('field_definition.listener')->onFieldDefinitionDelete($field);
    }
  }
  // If this is part of a configuration synchronization then the following
  // configuration updates are not necessary.
  $entity = reset($fields);
  if ($entity->isSyncing()) {
    return;
  }
  // Delete the associated field storages if they are not used anymore and are
  // not persistent.
  $storages_to_delete = [];
  foreach ($fields as $field) {
    $storage_definition = $field->getFieldStorageDefinition();
    if (!$field->deleted && !$field->isUninstalling() && $storage_definition->isDeletable()) {
      // Key by field UUID to avoid deleting the same storage twice.
      $storages_to_delete[$storage_definition->uuid()] = $storage_definition;
    }
  }
  if ($storages_to_delete) {
    \Drupal::entityTypeManager()->getStorage('field_storage_config')
      ->delete($storages_to_delete);
  }
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.