You are here

function name_field_config_delete in Name Field 8

Implements hook_entity_delete().

File

./name.module, line 747
Defines an API for displaying and inputing names.

Code

function name_field_config_delete(FieldConfigInterface $entity) {
  if (!$entity
    ->isSyncing() && $entity
    ->getTargetEntityTypeId() == 'user' && $entity
    ->getTargetBundle() == 'user' && Drupal::config('name.settings')
    ->get('user_preferred') == $entity
    ->getName()) {
    \Drupal::configFactory()
      ->getEditable('name.settings')
      ->set('user_preferred', '')
      ->save();
  }
}