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

EWPP-4280: Update webtools fields description to use the new cloud URL. #242

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_chart
label: 'Webtools chart snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://webtools.europa.eu/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_countdown
label: 'Webtools countdown snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://webtools.europa.eu/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://webtools.europa.eu/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_generic
label: 'Webtools snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://webtools.europa.eu/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://webtools.europa.eu/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_map
label: 'Webtools map snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://webtools.europa.eu/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://webtools.europa.eu/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_social_feed
label: 'Webtools social feed snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://webtools.europa.eu/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://webtools.europa.eu/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
35 changes: 35 additions & 0 deletions modules/oe_media_webtools/oe_media_webtools.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,38 @@ function oe_media_webtools_post_update_00005() {
return sprintf('The field description update for the following fields was skipped as their description was changed: %s.', implode(', ', $modified));
}
}

/**
* Update Webtools media fields description to use the cloud link.
*/
function oe_media_webtools_post_update_00006() {
$original_description = 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.';
$new_description = 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://webtools.europa.eu/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://webtools.europa.eu/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.';
$fields = [
'media.webtools_chart.oe_media_webtools',
'media.webtools_countdown.oe_media_webtools',
'media.webtools_generic.oe_media_webtools',
'media.webtools_map.oe_media_webtools',
'media.webtools_social_feed.oe_media_webtools',
];
$modified = [];

foreach ($fields as $field) {
$field_config = FieldConfig::load($field);
// If the field doesn't exist anymore, skip it.
if (!$field_config) {
continue;
}
// If the description has been customised by users, we don’t change it.
if ($original_description !== $field_config->get('description')) {
$modified[] = $field;
continue;
}
$field_config->setDescription($new_description);
$field_config->save();
}

if (!empty($modified)) {
return sprintf('The field description update for the following fields was skipped as their description was changed: %s.', implode(', ', $modified));
}
}