function webform_update_8181 in Webform 6.x
Same name and namespace in other branches
- 8.5 includes/webform.install.update.inc \webform_update_8181()
Issue #3103032: Move deprecated geocomplete element into a sub-module.
File
- includes/
webform.install.update.inc, line 3373 - Archived Webform update hooks.
Code
function webform_update_8181() {
$config_factory = \Drupal::configFactory();
$install_webform_location_geocomplete = FALSE;
foreach ($config_factory
->listAll('webform.webform.') as $webform_config_name) {
$webform_config = $config_factory
->get($webform_config_name);
$elements = $webform_config
->get('elements');
if (strpos($elements, 'webform_location_geocomplete') !== FALSE) {
$install_webform_location_geocomplete = TRUE;
break;
}
}
// Install and configure the webform_location_geocomplete.module.
$config = \Drupal::configFactory()
->getEditable('webform.settings');
if ($install_webform_location_geocomplete) {
// Install the webform_location_geocomplete.module.
\Drupal::service('module_installer')
->install([
'webform_location_geocomplete',
]);
// Move the default Google maps API key.
$api_key = $config
->get('element.default_google_maps_api_key');
if ($api_key) {
$config
->clear('element.default_google_maps_api_key');
$config
->set('third_party_settings.webform_location_geocomplete.default_google_maps_api_key', $api_key);
$config
->save();
}
}
// Remove 'webform_location_geocomplete' from excluded elements.
$config
->clear('element.excluded_elements.webform_location_geocomplete');
}