diff --git a/src/Service/UwNodeContent.php b/src/Service/UwNodeContent.php index 43608f251f2fdddd55147d216a6c9a5c46faf83f..f16f2c50e4f1d7118675d821fea68fceef2f6bd2 100644 --- a/src/Service/UwNodeContent.php +++ b/src/Service/UwNodeContent.php @@ -227,10 +227,12 @@ class UwNodeContent { $content_data['header']['author'] = $this->addToContentData('author', 'field_author'); } + // Get the hero image. if ($node_flags['get_hero']) { $content_data['hero_image'] = $this->addToContentData('sources', 'field_uw_hero_image'); } + // Get the listing image. if ($node_flags['get_listing_image']) { $content_data['listing_image'] = $this->addToContentData('sources', 'field_uw_blog_listing_page_image'); } @@ -273,10 +275,12 @@ class UwNodeContent { $content_data['header']['date'] = $this->addToContentData('date', 'field_uw_event_date'); } + // Get hero image. if ($node_flags['get_hero']) { $content_data['hero_image'] = $this->addToContentData('sources', 'field_uw_hero_image'); } + // Get listing image. if ($node_flags['get_listing_image']) { $content_data['listing_image'] = $this->addToContentData('sources', 'field_uw_event_listing_page_img'); } @@ -325,21 +329,39 @@ class UwNodeContent { */ public function getNewsContent(array $node_flags): array { - // The list of tags for news. - $tag_list = [ - 'field_uw_news_tags', - 'field_uw_audience', - ]; + // Get the content data. + $content_data = $this->setupContentData($node_flags); - return [ - 'title' => $node_flags['get_title'] ? TRUE : NULL, - 'url' => TRUE, - 'date' => $node_flags['get_header'] ? 'field_uw_news_date' : NULL, - 'sources' => $node_flags['get_image'] ? 'field_uw_news_listing_page_image' : NULL, - 'hero' => $node_flags['get_image'] ? 'field_uw_hero_image' : NULL, - 'content' => $node_flags['get_content'] ? 'field_uw_news_summary' : NULL, - 'tags' => $node_flags['get_footer'] ? $tag_list : NULL, - ]; + // Setup the header content. + if ($node_flags['get_header']) { + $content_data['header']['date'] = $this->addToContentData('date', 'field_uw_news_date'); + } + + // Get hero image. + if ($node_flags['get_hero']) { + $content_data['hero_image'] = $this->addToContentData('sources', 'field_uw_hero_image'); + } + + // Get listing image. + if ($node_flags['get_listing_image']) { + $content_data['listing_image'] = $this->addToContentData('sources', 'field_uw_news_listing_page_image'); + } + + // Setup the actual content. + if ($node_flags['get_content']) { + $content_data['content'] = $this->addToContentData('content', 'field_uw_news_summary'); + } + + // Get the tags. + $content_data['tags'] = $this->addToContentData( + 'terms', + [ + 'field_uw_news_tags', + 'field_uw_audience', + ] + ); + + return $content_data; } /**