You are here

function geolocation_yandex_update_8001 in Geolocation Field 8.3

Move settings to new configuration.

File

modules/geolocation_yandex/geolocation_yandex.install, line 38
Handle requirements.

Code

function geolocation_yandex_update_8001(&$sandbox) {
  $config_factory = \Drupal::configFactory();
  $old_config = $config_factory
    ->getEditable('yandex_maps.settings');
  if (!$old_config) {
    return;
  }
  $new_config = $config_factory
    ->getEditable('geolocation_yandex.settings');
  $new_config
    ->set('api_key', $old_config
    ->get('key'));
  $new_config
    ->save();
  $old_config
    ->delete();
  return \Drupal::translation()
    ->translate('Settings from old configuration moved to new one.');
}