From 0452c547c45db532775438103a5ece0cb814b9da Mon Sep 17 00:00:00 2001
From: ebremner <ebremner@uwaterloo.ca>
Date: Tue, 8 Jun 2021 12:14:26 -0400
Subject: [PATCH] ISTWCMS-4619: coding standards

---
 src/Service/UWService.php          | 30 ++++++++++++++++++++++++++----
 src/Service/UWServiceInterface.php |  2 ++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/Service/UWService.php b/src/Service/UWService.php
index 03ff39e1..9dcefa5e 100644
--- a/src/Service/UWService.php
+++ b/src/Service/UWService.php
@@ -8,7 +8,6 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
 use Drupal\Core\Url;
 use Drupal\node\Entity\Node;
-use Drupal\node\NodeInterface;
 use Drupal\simplify_menu\MenuItems;
 use Drupal\path_alias\AliasManager;
 
@@ -133,7 +132,15 @@ class UWService implements UWServiceInterface {
 
     // Setup the teaser data array, based on flags.
     switch ($teaser_type) {
+
       case 'blog':
+
+        // The list of tags for blogs.
+        $tag_list = [
+          'field_uw_blog_tags',
+          'field_uw_audience',
+        ];
+
         $teaser_data = [
           'title' => $get_header ? TRUE : NULL,
           'url' => TRUE,
@@ -141,29 +148,44 @@ class UWService implements UWServiceInterface {
           'author' => $get_header ? TRUE : NULL,
           'sources' => $get_image ? 'field_uw_blog_listing_page_image' : NULL,
           'content' => $get_content ? 'field_uw_blog_summary' : NULL,
-          'tags' => $get_footer ? ['field_uw_blog_tags', 'field_uw_audience'] : NULL
+          'tags' => $get_footer ? $tag_list : NULL,
         ];
         break;
 
       case 'events':
+
+        // The list of tags for events.
+        $tag_list = [
+          'field_uw_event_tags',
+          'field_uw_audience',
+          'field_uw_event_type',
+        ];
+
         $teaser_data = [
           'title' => $get_header ? TRUE : NULL,
           'url' => TRUE,
           'date' => $get_header ? 'field_uw_event_date' : NULL,
           'sources' => $get_image ? 'field_uw_event_listing_page_img' : NULL,
           'content' => $get_content ? 'field_uw_event_summary' : NULL,
-          'tags' => $get_footer ? ['field_uw_event_tags', 'field_uw_audience', 'field_uw_event_type'] : NULL,
+          'tags' => $get_footer ? $tag_list : NULL,
         ];
         break;
 
       case 'news':
+
+        // The list of tags for news.
+        $tag_list = [
+          'field_uw_news_tags',
+          'field_uw_audience',
+        ];
+
         $teaser_data = [
           'title' => $get_header ? TRUE : NULL,
           'url' => TRUE,
           'date' => $get_header ? 'field_uw_news_date' : NULL,
           'sources' => $get_image ? 'field_uw_news_listing_page_image' : NULL,
           'content' => $get_content ? 'field_uw_news_summary' : NULL,
-          'tags' => $get_footer ? ['field_uw_news_tags', 'field_uw_audience'] : NULL,
+          'tags' => $get_footer ? $tag_list : NULL,
         ];
         break;
     }
diff --git a/src/Service/UWServiceInterface.php b/src/Service/UWServiceInterface.php
index b5f52815..dbfc43e2 100644
--- a/src/Service/UWServiceInterface.php
+++ b/src/Service/UWServiceInterface.php
@@ -38,6 +38,8 @@ interface UWServiceInterface {
    *   List of variables to return.
    * @param string $teaser_type
    *   Teaser type.
+   * @param string $teaser_content
+   *   The type of content to get, values are all, header or footer.
    *
    * @return array
    *   Array of variables and their values.
-- 
GitLab