diff --git a/src/Service/UWService.php b/src/Service/UWService.php index 81d953292954eeb275b4e7f6292b7be19736184c..166726de68e60d4679aaad658fbece1e4a7c691e 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') { @@ -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_event', + 'uw_ct_news_item', + 'uw_ct_web_page', + 'uw_ct_catalog_item', + 'uw_ct_contact', + 'uw_ct_profile', + ]; + break; + + case 'layout_container': + $preprocess = [ + 'uw_ct_blog', + 'uw_ct_news_item', + 'uw_ct_event', + 'uw_ct_contact', + 'uw_ct_profile', + ]; + break; + + case 'teaser': + $preprocess = [ + 'uw_ct_blog', + 'uw_ct_event', + 'uw_ct_news_item', + 'uw_ct_web_page', + 'uw_ct_catalog_item', + 'uw_ct_contact', + 'uw_ct_profile', + ]; + 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..702d9edb04b69410be52ee328f971d1a9a2b3837 100644 --- a/src/Service/UWServiceInterface.php +++ b/src/Service/UWServiceInterface.php @@ -61,10 +61,12 @@ 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.