public static FieldConfig::postDelete(EntityStorageInterface $storage, array $fields)
Acts on deleted entities before the delete hook is invoked.
Used after the entities are deleted but before invoking the delete hook.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.
Overrides Entity::postDelete
File
- core/modules/field/src/Entity/FieldConfig.php, line 211
 
Class
- FieldConfig
 - Defines the Field entity.
 
Namespace
Drupal\field\Entity
Code
public static function postDelete(EntityStorageInterface $storage, array $fields) {
  // Clear the cache upfront, to refresh the results of getBundles().
  \Drupal::entityManager()->clearCachedFieldDefinitions();
  // Notify the entity storage.
  foreach ($fields as $field) {
    if (!$field->deleted) {
      \Drupal::entityManager()->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 = array();
  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::entityManager()->getStorage('field_storage_config')->delete($storages_to_delete);
  }
}
Please login to continue.