Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-7249: Adds update hook to add title field for popular services pa… #413

Merged
merged 3 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dependencies:
config:
- field.field.paragraph.popular_services.field_service_items
- paragraphs.paragraphs_type.popular_services
- field.field.paragraph.popular_services.field_popular_services_title
module:
- paragraphs
_core:
Expand All @@ -13,9 +14,17 @@ targetEntityType: paragraph
bundle: popular_services
mode: default
content:
field_popular_services_title:
type: string_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
field_service_items:
type: paragraphs
weight: 0
weight: 1
region: content
settings:
title: Paragraph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dependencies:
config:
- field.field.paragraph.popular_services.field_service_items
- paragraphs.paragraphs_type.popular_services
- field.field.paragraph.popular_services.field_popular_services_title
module:
- entity_reference_revisions
_core:
Expand All @@ -13,14 +14,22 @@ targetEntityType: paragraph
bundle: popular_services
mode: default
content:
field_popular_services_title:
type: string
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
weight: 0
region: content
field_service_items:
type: entity_reference_revisions_entity_view
label: hidden
settings:
view_mode: default
link: ''
third_party_settings: { }
weight: 0
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.paragraph.field_popular_services_title
- paragraphs.paragraphs_type.popular_services
id: paragraph.popular_services.field_popular_services_title
field_name: field_popular_services_title
entity_type: paragraph
bundle: popular_services
label: Title
description: 'If this field is left empty, the title will be "Popular services"'
required: false
translatable: false
default_value:
khalima marked this conversation as resolved.
Show resolved Hide resolved
-
value: 'Popular services'
default_value_callback: ''
settings: { }
field_type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
langcode: en
status: true
dependencies:
module:
- paragraphs
id: paragraph.field_popular_services_title
field_name: field_popular_services_title
entity_type: paragraph
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
default_value:
khalima marked this conversation as resolved.
Show resolved Hide resolved
-
value: 'Suosittuja palveluja'
description: 'Jos kenttä jätetään tyhjäksi, otsikoksi tulee "Suosittuja palveluja"'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
default_value:
khalima marked this conversation as resolved.
Show resolved Hide resolved
-
value: 'Populära tjänster'
description: 'Om detta lämnas tomt, titel är "Populära tjänster"'
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
core.entity_form_display.paragraph.popular_services.default:
expected_config:
content:
field_service_items:
weight: 0
update_actions:
add:
content:
field_popular_services_title:
type: string_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
change:
content:
field_service_items:
weight: 1
core.entity_view_display.paragraph.popular_services.default:
expected_config:
content:
field_service_items:
weight: 0
update_actions:
add:
content:
field_popular_services_title:
type: string
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
weight: 0
region: content
change:
content:
field_service_items:
weight: 1
31 changes: 30 additions & 1 deletion helfi_features/helfi_content/helfi_content.install
Original file line number Diff line number Diff line change
Expand Up @@ -973,4 +973,33 @@ function helfi_content_update_9038() {
foreach ($configurations as $configuration) {
ConfigHelper::installNewConfigTranslation($configTranslationLocation, $configuration);
}
}
}

/**
* Update the popular service paragraph with new field.
*/
function helfi_content_update_9039() {
/** @var \Drupal\update_helper\Updater $updateHelper */
$updateHelper = \Drupal::service('update_helper.updater');

// Add the new fields for popular services paragraph.
$configLocation = dirname(__FILE__) . '/config/install/';
$configTranslationLocation = dirname(__FILE__) . '/config/language/';

// Key field storage and value is field configuration.
$configFields = [
'field.storage.paragraph.field_popular_services_title' => 'field.field.paragraph.popular_services.field_popular_services_title',
];

// Install title field and its translations.
foreach ($configFields as $field_storage => $field_config) {
ConfigHelper::installNewField($configLocation, $field_storage, $field_config);
ConfigHelper::installNewConfigTranslation($configTranslationLocation, $field_config);
}

// Execute configuration update definitions with logging of success.
$updateHelper->executeUpdate('helfi_content', 'helfi_content_update_9039');

// Output logged messages to related channel of update execution.
return $updateHelper->logger()->output();
}