diff --git a/config/install/workflows.workflow.localgov_alert_banners.yml b/config/install/workflows.workflow.localgov_alert_banners.yml index 631d5971..e67116a7 100644 --- a/config/install/workflows.workflow.localgov_alert_banners.yml +++ b/config/install/workflows.workflow.localgov_alert_banners.yml @@ -5,6 +5,9 @@ dependencies: - localgov_alert_banner.localgov_alert_banner_type.localgov_alert_banner module: - content_moderation + enforced: + module: + - localgov_alert_banner id: localgov_alert_banners label: 'Alert banners' type: content_moderation diff --git a/localgov_alert_banner.module b/localgov_alert_banner.module index 93b073d4..b60c242d 100644 --- a/localgov_alert_banner.module +++ b/localgov_alert_banner.module @@ -121,3 +121,17 @@ function localgov_alert_banner_configure_scheduled_transitions() { } user_role_grant_permissions('emergency_publisher', $permissions); } + +/** + * Implements hook_preprocess_field(). + */ +function localgov_alert_banner_preprocess_field(&$variables) { + if ($variables['element']['#field_name'] == 'link' && $variables['element']['#bundle'] == 'localgov_alert_banner') { + foreach ($variables['element']['#items'] as $item) { + if (empty($item->getValue()['title'])) { + $default_text = t('More information'); + $variables['items'][0]['content']['#title'] = $default_text; + } + } + } +} diff --git a/localgov_alert_banner.page.inc b/localgov_alert_banner.page.inc index 9aef9047..a5084594 100644 --- a/localgov_alert_banner.page.inc +++ b/localgov_alert_banner.page.inc @@ -7,9 +7,7 @@ * Page callback for Alert banner entities. */ -use Drupal\Core\Link; use Drupal\Core\Render\Element; -use Drupal\Core\Url; /** * Prepares variables for Alert banner templates. @@ -33,13 +31,6 @@ function template_preprocess_localgov_alert_banner(array &$variables) { /** @var \Drupal\localgov_alert_banner\Entity\AlertBannerEntity $entity */ $entity = $variables['elements']['#localgov_alert_banner']; - // Set default link text if field exists. - if ($entity->hasField('link')) { - if ($entity->get('link')->title === '') { - $variables['content']['link'] = Link::fromTextAndUrl(t('More information'), Url::fromUri($entity->get('link')->uri))->toString(); - } - } - // Non-content variables. $variables['display_title'] = $entity->get('display_title')->value; $variables['remove_hide_link'] = $entity->get('remove_hide_link')->value;