diff --git a/modules/opd_podcast/opd_podcast.module b/modules/opd_podcast/opd_podcast.module index e1d1f2a6d..eab0e540d 100644 --- a/modules/opd_podcast/opd_podcast.module +++ b/modules/opd_podcast/opd_podcast.module @@ -80,6 +80,14 @@ function opd_podcast_tokens(string $type, array $tokens, array $data, array $opt assert(!is_null($guests[0])); assert($guests[0] instanceof TermInterface); + // TODO: allow for more than two guests. + if (count($guests) === 2) { + assert($guests[1] instanceof TermInterface); + + $replacements[$original] = sprintf('%s %s %s', $guests[0]->label(), t('and'), $guests[1]->label()); + break; + } + $replacements[$original] = $guests[0]->label(); break; } diff --git a/modules/opd_podcast/tests/src/Kernel/PodcastTokenTest.php b/modules/opd_podcast/tests/src/Kernel/PodcastTokenTest.php index fb22790b1..73a26583f 100644 --- a/modules/opd_podcast/tests/src/Kernel/PodcastTokenTest.php +++ b/modules/opd_podcast/tests/src/Kernel/PodcastTokenTest.php @@ -44,6 +44,7 @@ class PodcastTokenTest extends BrowserTestBase { public function podcastNodeProvider(): \Generator { return [ yield 'Single guest' => [['Matt Glaman'], 'Matt Glaman'], + yield 'Two guests' => [['Emma Horrell', 'Luke McCormick'], 'Emma Horrell and Luke McCormick'], ]; }