You are here

function double_field_field_storage_config_update in Double Field 4.x

Same name and namespace in other branches
  1. 8.3 double_field.module \double_field_field_storage_config_update()

Implements hook_ENTITY_TYPE_update().

File

./double_field.module, line 52
Primary module hooks for Double Field module.

Code

function double_field_field_storage_config_update(EntityInterface $entity) : void {

  /* @var \Drupal\field\Entity\FieldStorageConfig  $entity */
  if ($entity
    ->getType() == 'double_field') {
    $settings = $entity
      ->getSettings();
    $original_settings = $entity->original
      ->getSettings();
    $first_type_is_changed = $settings['storage']['first']['type'] != $original_settings['storage']['first']['type'];
    $second_type_is_changed = $settings['storage']['second']['type'] != $original_settings['storage']['second']['type'];
    if ($first_type_is_changed || $second_type_is_changed) {
      Drupal::messenger()
        ->addWarning(t('Since storage type has been changed you need to verify the configuration of corresponding widget on form display page.'));
    }
  }
}