Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-gao committed Sep 11, 2024
1 parent abef661 commit 8d1c7d6
Show file tree
Hide file tree
Showing 9 changed files with 398 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
langcode: en
status: true
dependencies:
config:
- field.field.taxonomy_term.captcha_widgets.field_captcha_type
- field.field.taxonomy_term.captcha_widgets.field_site_key
- taxonomy.vocabulary.captcha_widgets
module:
- path
- text
id: taxonomy_term.captcha_widgets.default
targetEntityType: taxonomy_term
bundle: captcha_widgets
mode: default
content:
description:
type: text_textarea
weight: 4
region: content
settings:
rows: 5
placeholder: ''
third_party_settings: { }
field_captcha_type:
type: options_select
weight: 1
region: content
settings: { }
third_party_settings: { }
field_site_key:
type: string_textfield
weight: 3
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
name:
type: string_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
path:
type: path
weight: 5
region: content
settings: { }
third_party_settings: { }
simple_sitemap:
weight: 10
region: content
settings: { }
third_party_settings: { }
status:
type: boolean_checkbox
weight: 6
region: content
settings:
display_label: true
third_party_settings: { }
hidden: { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
langcode: en
status: true
dependencies:
config:
- field.field.taxonomy_term.captcha_widgets.field_captcha_type
- field.field.taxonomy_term.captcha_widgets.field_site_key
- taxonomy.vocabulary.captcha_widgets
module:
- options
- text
id: taxonomy_term.captcha_widgets.default
targetEntityType: taxonomy_term
bundle: captcha_widgets
mode: default
content:
description:
type: text_default
label: hidden
settings: { }
third_party_settings: { }
weight: 0
region: content
field_captcha_type:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 2
region: content
field_site_key:
type: string
label: above
settings:
link_to_entity: false
third_party_settings: { }
weight: 1
region: content
hidden:
search_api_excerpt: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_captcha_type
- taxonomy.vocabulary.captcha_widgets
module:
- options
id: taxonomy_term.captcha_widgets.field_captcha_type
field_name: field_captcha_type
entity_type: taxonomy_term
bundle: captcha_widgets
label: 'Captcha type'
description: ''
required: true
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: list_string
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_site_key
- taxonomy.vocabulary.captcha_widgets
id: taxonomy_term.captcha_widgets.field_site_key
field_name: field_site_key
entity_type: taxonomy_term
bundle: captcha_widgets
label: 'Site key'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string
29 changes: 29 additions & 0 deletions config/optional/field.storage.taxonomy_term.field_captcha_type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
langcode: en
status: true
dependencies:
module:
- options
- taxonomy
id: taxonomy_term.field_captcha_type
field_name: field_captcha_type
entity_type: taxonomy_term
type: list_string
settings:
allowed_values:
-
value: google_recaptcha_v3
label: 'Google reCAPTCHA v3'
-
value: google_recaptcha_v2
label: 'Google reCAPTCHA v2'
-
value: cloudfare_turnstile
label: 'Cloudfare Turnstile'
allowed_values_function: ''
module: options
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
20 changes: 20 additions & 0 deletions config/optional/field.storage.taxonomy_term.field_site_key.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
langcode: en
status: true
dependencies:
module:
- taxonomy
id: taxonomy_term.field_site_key
field_name: field_site_key
entity_type: taxonomy_term
type: string
settings:
max_length: 255
case_sensitive: false
is_ascii: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
7 changes: 7 additions & 0 deletions config/optional/taxonomy.vocabulary.captcha_widgets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
langcode: en
status: true
dependencies: { }
name: 'CAPTCHA widgets'
vid: captcha_widgets
description: ''
weight: 0
27 changes: 27 additions & 0 deletions tide_webform.install
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,30 @@ function tide_webform_install() {
TideOperation::installWebformConfig();
TideOperation::accessTextEditorInWebform();
}

/**
* Import configs for Captcha feature.
*/
function tide_webform_update_10001() {
$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();
}
}
}
Loading

0 comments on commit 8d1c7d6

Please sign in to comment.