diff --git a/modules/custom/wxt_core/config/install/wxt_core_countries.settings.yml b/modules/custom/wxt_core/config/install/wxt_core.settings.countries.yml similarity index 100% rename from modules/custom/wxt_core/config/install/wxt_core_countries.settings.yml rename to modules/custom/wxt_core/config/install/wxt_core.settings.countries.yml diff --git a/modules/custom/wxt_core/src/CountriesManager.php b/modules/custom/wxt_core/src/CountriesManager.php index ac605a34..7059b503 100644 --- a/modules/custom/wxt_core/src/CountriesManager.php +++ b/modules/custom/wxt_core/src/CountriesManager.php @@ -94,7 +94,7 @@ public function listCounties() { */ public function whitelistedOptions() { $standartCountries = $this->listCounties(); - $config = $this->configFactory->get('wxt_core_countries.settings'); + $config = $this->configFactory->get('wxt_core.settings.countries'); $countries = $config->get('countries'); foreach ($countries as $abbr => $checkbox) { if ($checkbox != 0) { @@ -108,7 +108,7 @@ public function whitelistedOptions() { * Returns the sorted whitelisted. */ public function whitelistedOptionsSorted() { - $config = $this->configFactory->get('wxt_core_countries.settings'); + $config = $this->configFactory->get('wxt_core.settings.countries'); $whitelist = $this->whitelistedOptions(); switch ($config->get('whitelist-sort')) { case 'alpha': diff --git a/modules/custom/wxt_core/src/Form/CountriesWhitelistForm.php b/modules/custom/wxt_core/src/Form/CountriesWhitelistForm.php index 18e5d4fa..9c565d2e 100644 --- a/modules/custom/wxt_core/src/Form/CountriesWhitelistForm.php +++ b/modules/custom/wxt_core/src/Form/CountriesWhitelistForm.php @@ -16,7 +16,7 @@ class CountriesWhitelistForm extends ConfigFormBase { * {@inheritdoc} */ protected function getEditableConfigNames() { - return ['wxt_core_countries.settings']; + return ['wxt_core.settings.countries']; } /** @@ -31,7 +31,7 @@ public function getFormId() { */ public function buildForm(array $form, FormStateInterface $form_state) { $countryManager = \Drupal::service('wxt.country_whitelist'); - $config = $this->config('wxt_core_countries.settings'); + $config = $this->config('wxt_core.settings.countries'); $savedCountries = $config->get('countries'); $whitelisted = $countryManager->getCountryData(); $options = $countryManager->listCounties(); @@ -96,7 +96,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $this->config('wxt_core_countries.settings') + $this->config('wxt_core.settings.countries') ->set('countries', $form_state->getValue('countries')) ->set('whitelist-sort', $form_state->getValue('whitelist-sort')) ->save(); diff --git a/modules/custom/wxt_core/wxt_core.install b/modules/custom/wxt_core/wxt_core.install index 8c919c32..88ccb9b3 100644 --- a/modules/custom/wxt_core/wxt_core.install +++ b/modules/custom/wxt_core/wxt_core.install @@ -675,17 +675,31 @@ function wxt_core_update_8500() { * Setup CountryManager lists [#3111375]. */ function wxt_core_update_8501() { - $config_namespace = 'wxt_core_countries.settings'; - $module_handler = \Drupal::service('module_handler'); - $module_path = $module_handler->getModule('wxt_core')->getPath(); - $path = DRUPAL_ROOT . '/' . $module_path . '/config/install/' . $config_namespace . '.yml'; - $country_data = Yaml::parse(\file_get_contents($path)); + // [#3399929] wxt_core_update_8502 in favour +} - // Get the configuration factory service. +/** + * [#3399929] Change wxt_core countries config namespace. + */ +function wxt_core_update_8502() { + $legacy = 'wxt_core_countries.settings'; + $updated = 'wxt_core.settings.countries'; $config_factory = \Drupal::configFactory(); - - // Save the configuration using the loaded data. - $config = $config_factory->getEditable($config_namespace); - $config->setData($country_data); - $config->save(); + $module_handler = \Drupal::service('module_handler'); + $module_path = $module_handler->getModule('wxt_core')->getPath(); + $path = DRUPAL_ROOT . '/' . $module_path . '/config/install/' . $updated . '.yml'; + $hasUpdated = $config_factory->get($legacy)->isNew(); + if ($hasUpdated) { + $country_data = $config_factory->getEditable($legacy); + $config = $config_factory->getEditable($updated); + $config->setData($country_data); + $config->save(); + // Delete old data. + $country_data->delete(); + } else { + $country_data = Yaml::parse(\file_get_contents($path)); + $config = $config_factory->getEditable($updated); + $config->setData($country_data); + $config->save(); + } } diff --git a/modules/custom/wxt_ext/wxt_ext_webform/wxt_ext_webform.module b/modules/custom/wxt_ext/wxt_ext_webform/wxt_ext_webform.module index 21d9f50c..2ac0202c 100644 --- a/modules/custom/wxt_ext/wxt_ext_webform/wxt_ext_webform.module +++ b/modules/custom/wxt_ext/wxt_ext_webform/wxt_ext_webform.module @@ -125,7 +125,7 @@ function _gcweb_did_you_find_form_ajax_submit($form, $form_state) { * Implements hook_webform_options_WEBFORM_OPTIONS_ID_alter() for country names options. */ function wxt_ext_webform_webform_options_country_names_alter(array &$options, array $element = []) { - $config = \Drupal::configFactory()->get('wxt_core_countries.settings'); + $config = \Drupal::configFactory()->get('wxt_core.settings.countries'); if ($config->get('webform-override') == 1) { $countryManager = \Drupal::service('wxt.country_whitelist'); $options = $countryManager->whitelistedOptionsSorted(); @@ -145,7 +145,7 @@ function wxt_ext_webform_form_wxt_core_countries_settings_form_alter(&$form, For $form['webform-box']['webform-override'] = [ '#type' => 'checkbox', '#title' => t('Override Webform Options for Country Names'), - '#default_value' => \Drupal::config('wxt_core_countries.settings')->get('webform-override'), + '#default_value' => \Drupal::config('wxt_core.settings.countries')->get('webform-override'), '#description' => t('@link can be edited or reset in many circumstances.', ['@link' => $link->toString()]), ]; $form['#submit'][] = 'wxt_ext_webform_form_wxt_core_countries_submit'; @@ -156,7 +156,7 @@ function wxt_ext_webform_form_wxt_core_countries_settings_form_alter(&$form, For */ function wxt_ext_webform_form_wxt_core_countries_submit(&$form, FormStateInterface $form_state) { \Drupal::configFactory() - ->getEditable('wxt_core_countries.settings') + ->getEditable('wxt_core.settings.countries') ->set('webform-override', $form_state->getValue('webform-override')) ->save(); }