This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtide_webform.install
54 lines (48 loc) · 1.9 KB
/
tide_webform.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @file
* Install file.
*/
use Drupal\tide_webform\TideOperation;
/**
* Implements hook_install().
*/
function tide_webform_install() {
TideOperation::installWebformConfig();
TideOperation::accessTextEditorInWebform();
}
/**
* Enables webform_wizard_page element.
*/
function tide_webform_update_10001() {
$config = \Drupal::configFactory()->getEditable('webform.settings');
$excluded_elements_value = $config->get('element.excluded_elements');
unset($excluded_elements_value['webform_wizard_page']);
$config->set('element.excluded_elements', $excluded_elements_value);
$config->save();
}
/**
* Import configs for Captcha feature.
*/
function tide_webform_update_10002() {
$configs = [
'taxonomy.vocabulary.captcha_widgets' => 'taxonomy_vocabulary',
'field.storage.taxonomy_term.field_site_key' => 'field_storage_config',
'field.storage.taxonomy_term.field_captcha_type' => 'field_storage_config',
'field.field.taxonomy_term.captcha_widgets.field_site_key' => 'field_config',
'field.field.taxonomy_term.captcha_widgets.field_captcha_type' => 'field_config',
'core.entity_view_display.taxonomy_term.captcha_widgets.default' => 'entity_view_display',
'core.entity_form_display.taxonomy_term.captcha_widgets.default' => 'entity_form_display',
];
\Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/helpers');
$config_location = [\Drupal::service('extension.list.module')->getPath('tide_webform') . '/config/optional'];
foreach ($configs as $config_name => $type) {
$config_read = _tide_read_config($config_name, $config_location, TRUE);
$storage = \Drupal::entityTypeManager()->getStorage($type);
$id = $storage->getIDFromConfigName($config_name, $storage->getEntityType()->getConfigPrefix());
if ($storage->load($id) == NULL) {
$config_entity = $storage->createFromStorageRecord($config_read);
$config_entity->save();
}
}
}