public static FieldConfig::preDelete(EntityStorageInterface $storage, array $fields)
Acts on entities before they are deleted and before hooks are invoked.
Used before the entities are deleted and 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 ConfigEntityBase::preDelete
File
- core/modules/field/src/Entity/FieldConfig.php, line 190
 
Class
- FieldConfig
 - Defines the Field entity.
 
Namespace
Drupal\field\Entity
Code
public static function preDelete(EntityStorageInterface $storage, array $fields) {
  $state = \Drupal::state();
  parent::preDelete($storage, $fields);
  // Keep the field definitions in the state storage so we can use them
  // later during field_purge_batch().
  $deleted_fields = $state->get('field.field.deleted') ? : array();
  foreach ($fields as $field) {
    if (!$field->deleted) {
      $config = $field->toArray();
      $config['deleted'] = TRUE;
      $config['field_storage_uuid'] = $field->getFieldStorageDefinition()->uuid();
      $deleted_fields[$field->uuid()] = $config;
    }
  }
  $state->set('field.field.deleted', $deleted_fields);
}
Please login to continue.