diff --git a/src/Service/UWService.php b/src/Service/UWService.php index 81d953292954eeb275b4e7f6292b7be19736184c..f08feb7c1cb1950ed3371fd8fa0b90ff146fff4b 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -114,7 +114,7 @@ class UWService implements UWServiceInterface { $get_content = FALSE; $get_title = TRUE; - $featured_image = $this->uwGetFeaturedImageContentTypes(); + $featured_image = $this->uwGetNodePreprocessing('featured_image'); // Setup flags based on teaser content argument. if ($content == 'all') { @@ -317,7 +317,7 @@ class UWService implements UWServiceInterface { break; case 'groups': - $node_data['groups'] = $this->uwGetTermsFromEntityField($node->field_uw_ct_contact_group, 'tags'); + $node_data['groups'] = $this->uwGetTermsFromEntityField($node->$data, 'tags'); break; case 'image': @@ -362,12 +362,59 @@ class UWService implements UWServiceInterface { /** * {@inheritDoc} */ - public function uwGetFeaturedImageContentTypes(): array { - return [ - 'uw_ct_blog' => 'field_uw_blog_listing_page_image', - 'uw_ct_event' => 'field_uw_event_listing_page_img', - 'uw_ct_news_item' => 'field_uw_news_listing_page_image', - ]; + public function uwGetNodePreprocessing(string $type): array { + + // Ensure that we return at least empty array. + $preprocess = []; + + // Get the array of things to be proprocessed based + // on the type. + switch ($type) { + + case 'full': + $preprocess = [ + 'uw_ct_blog', + 'uw_ct_catalog_item', + 'uw_ct_contact', + 'uw_ct_event', + 'uw_ct_news_item', + 'uw_ct_profile', + 'uw_ct_web_page', + ]; + break; + + case 'layout_container': + $preprocess = [ + 'uw_ct_blog', + 'uw_ct_contact', + 'uw_ct_event', + 'uw_ct_news_item', + 'uw_ct_profile', + ]; + break; + + case 'teaser': + $preprocess = [ + 'uw_ct_blog', + 'uw_ct_catalog_item', + 'uw_ct_contact', + 'uw_ct_event', + 'uw_ct_news_item', + 'uw_ct_profile', + 'uw_ct_web_page', + ]; + break; + + case 'featured_image': + $preprocess = [ + 'uw_ct_blog' => 'field_uw_blog_listing_page_image', + 'uw_ct_event' => 'field_uw_event_listing_page_img', + 'uw_ct_news_item' => 'field_uw_news_listing_page_image', + ]; + break; + } + + return $preprocess; } /** @@ -380,7 +427,7 @@ class UWService implements UWServiceInterface { // Get the list of content types that are allowed to have // feature images from our service. - $featured_image = $this->uwGetFeaturedImageContentTypes(); + $featured_image = $this->uwGetNodePreprocessing('featured_image'); // If node is allowed to have a featured image, make sure that // node actually has an image. diff --git a/src/Service/UWServiceInterface.php b/src/Service/UWServiceInterface.php index 00ede8c0879086843043f99cda6a834d40cbe33d..b24c820a268bc276eb79022eb792651d4412b944 100644 --- a/src/Service/UWServiceInterface.php +++ b/src/Service/UWServiceInterface.php @@ -61,10 +61,13 @@ interface UWServiceInterface { /** * Gets content types that have feature images. * + * @param string $type + * The type of preprocess (node, teaser, featured_image, etc). + * * @return array * Array of content types that has featured images. */ - public function uwGetFeaturedImageContentTypes(): array; + public function uwGetNodePreprocessing(string $type): array; /** * Gets dates from node.