diff --git a/modules/oe_theme_helper/oe_theme_helper.services.yml b/modules/oe_theme_helper/oe_theme_helper.services.yml index 8d0a60740d..bf03787ab3 100644 --- a/modules/oe_theme_helper/oe_theme_helper.services.yml +++ b/modules/oe_theme_helper/oe_theme_helper.services.yml @@ -47,3 +47,7 @@ services: oe_theme_helper.external_links: class: Drupal\oe_theme_helper\ExternalLinks arguments: ['@config.factory'] + oe_theme_helper.flag_options_subscriber: + class: Drupal\oe_theme_helper\EventSubscriber\FlagOptionsEventSubscriber + tags: + - { name: event_subscriber } diff --git a/modules/oe_theme_helper/src/EventSubscriber/FlagOptionsEventSubscriber.php b/modules/oe_theme_helper/src/EventSubscriber/FlagOptionsEventSubscriber.php new file mode 100644 index 0000000000..76e6c39d8a --- /dev/null +++ b/modules/oe_theme_helper/src/EventSubscriber/FlagOptionsEventSubscriber.php @@ -0,0 +1,51 @@ + 'alterFlagOptions', + ]; + } + + /** + * Alter the list of allowed flag icons. + * + * @param \Drupal\oe_paragraphs\Event\FlagOptionsEvent $event + * The event. + */ + public function alterFlagOptions(FlagOptionsEvent $event): void { + $options = $event->getFlagOptions(); + $options['albania'] = $this->t('Albania'); + $options['bosnia-and-herzegovina'] = $this->t('Bosnia and Herzegovina'); + $options['georgia'] = $this->t('Georgia'); + $options['iceland'] = $this->t('Iceland'); + $options['moldova'] = $this->t('Moldova'); + $options['montenegro'] = $this->t('Montenegro'); + $options['north-macedonia'] = $this->t('North Macedonia'); + $options['norway'] = $this->t('Norway'); + $options['serbia'] = $this->t('Serbia'); + $options['switzerland'] = $this->t('Switzerland'); + $options['turkey'] = $this->t('Turkey'); + $options['ukraine'] = $this->t('Ukraine'); + ksort($options); + $event->setFlagOptions($options); + } + +} diff --git a/tests/src/Kernel/Paragraphs/IllustrationListsParagraphsTest.php b/tests/src/Kernel/Paragraphs/IllustrationListsParagraphsTest.php index 6c7b7cdfef..a8b05ab0e6 100644 --- a/tests/src/Kernel/Paragraphs/IllustrationListsParagraphsTest.php +++ b/tests/src/Kernel/Paragraphs/IllustrationListsParagraphsTest.php @@ -93,7 +93,7 @@ public function testIllustrationListFlagsRendering(): void { $paragraph = Paragraph::create([ 'type' => 'oe_illustration_item_flag', - 'field_oe_flag' => 'finland', + 'field_oe_flag' => 'north-macedonia', ]); $paragraph->save(); $items[] = $paragraph; @@ -135,7 +135,7 @@ public function testIllustrationListFlagsRendering(): void { 'icon' => 'france', 'value' => 'Highlighted Term 3', ], [ - 'icon' => 'finland', + 'icon' => 'north-macedonia', ], ], 'centered' => FALSE, @@ -164,7 +164,7 @@ public function testIllustrationListFlagsRendering(): void { 'icon' => 'france-square', 'value' => 'Highlighted Term 3', ], [ - 'icon' => 'finland-square', + 'icon' => 'north-macedonia-square', ], ], ];