Skip to content

Commit ccb2f52

Browse files
Issue #3501085 by richardgaunt, fionamorrison23, joshua1234511: Added paragraph component. (#1405)
1 parent 315f429 commit ccb2f52

7 files changed

+80
-6
lines changed

web/themes/contrib/civictheme/civictheme.post_update.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,3 +864,77 @@ function civictheme_post_update_update_editor_allowed_field(): string {
864864
}
865865
return (string) new TranslatableMarkup('Allowed tags setting not set, aborting update.');
866866
}
867+
868+
/**
869+
* Add civictheme_message paragraph type and enable it for civictheme page.
870+
*
871+
* @SuppressWarnings(PHPMD.StaticAccess)
872+
*/
873+
function civictheme_post_update_add_civictheme_message_paragraph(): string {
874+
$new_configs = [
875+
// Paragraph type definition.
876+
'paragraphs.paragraphs_type.civictheme_message' => 'paragraphs_type',
877+
'field.storage.paragraph.field_c_p_message_type' => 'field_storage_config',
878+
'field.field.paragraph.civictheme_message.field_c_p_background' => 'field_config',
879+
'field.field.paragraph.civictheme_message.field_c_p_content' => 'field_config',
880+
'field.field.paragraph.civictheme_message.field_c_p_message_type' => 'field_config',
881+
'field.field.paragraph.civictheme_message.field_c_p_theme' => 'field_config',
882+
'field.field.paragraph.civictheme_message.field_c_p_title' => 'field_config',
883+
'field.field.paragraph.civictheme_message.field_c_p_vertical_spacing' => 'field_config',
884+
'core.entity_form_display.paragraph.civictheme_message.default' => 'entity_form_display',
885+
'core.entity_view_display.paragraph.civictheme_message.default' => 'entity_view_display',
886+
];
887+
888+
$config_path = \Drupal::service('extension.list.theme')->getPath('civictheme') . '/config/install';
889+
\Drupal::classResolver(CivicthemeUpdateHelper::class)->createConfigs($new_configs, $config_path);
890+
891+
// Enable civictheme_message for civictheme_page.
892+
$field_config_name = 'field.field.node.civictheme_page.field_c_n_components';
893+
$field_config = \Drupal::configFactory()->getEditable($field_config_name);
894+
895+
if (!$field_config->isNew()) {
896+
$handler_settings = $field_config->get('settings.handler_settings') ?: [];
897+
// Ensure target_bundles exists.
898+
if (!isset($handler_settings['target_bundles'])) {
899+
$handler_settings['target_bundles'] = [];
900+
}
901+
$handler_settings['target_bundles']['civictheme_message'] = 'civictheme_message';
902+
903+
// Ensure target_bundles_drag_drop exists.
904+
if (!isset($handler_settings['target_bundles_drag_drop'])) {
905+
$handler_settings['target_bundles_drag_drop'] = [];
906+
}
907+
$handler_settings['target_bundles_drag_drop']['civictheme_message'] = [
908+
'weight' => -52,
909+
'enabled' => TRUE,
910+
];
911+
912+
$field_config->set('settings.handler_settings', $handler_settings);
913+
$field_config->save();
914+
}
915+
916+
return (string) new TranslatableMarkup('Added civictheme_message paragraph type and enabled it for civictheme page.');
917+
}
918+
919+
/**
920+
* Update the field description for field_c_p_background.
921+
*/
922+
function civictheme_post_update_update_field_c_p_background_description(): string {
923+
$field_configs = [
924+
'field.field.paragraph.civictheme_accordion.field_c_p_background',
925+
'field.field.paragraph.civictheme_content.field_c_p_background',
926+
'field.field.paragraph.civictheme_map.field_c_p_background',
927+
'field.field.paragraph.civictheme_promo.field_c_p_background',
928+
'field.field.paragraph.civictheme_webform.field_c_p_background',
929+
];
930+
foreach ($field_configs as $field_config_name) {
931+
$field_config = \Drupal::configFactory()->getEditable($field_config_name);
932+
933+
if (!$field_config->isNew()) {
934+
$field_config->set('description', 'Apply a themed background colour and provide horizontal spacing to the component');
935+
$field_config->save();
936+
}
937+
}
938+
939+
return (string) new TranslatableMarkup('Updated field description for field_c_p_background.');
940+
}

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_accordion.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_accordion
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: true
1515
default_value:

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_content.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_content
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: false
1515
default_value:

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_map.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_map
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: true
1515
default_value:

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_message.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_message
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: false
1515
default_value:

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_promo.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_promo
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: false
1515
default_value:

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_webform.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_webform
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: true
1515
default_value:

0 commit comments

Comments
 (0)