Skip to content
Snippets Groups Projects
Commit e9d1c510 authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-4704: moving all the types of node preprocessing to the service, now...

ISTWCMS-4704: moving all the types of node preprocessing to the service, now no editing of the theme is required for nodes and teasers
parent 1ee84c8e
No related branches found
No related tags found
1 merge request!113ISTWCMS-4704: moving all the types of node preprocessing to the service, now...
......@@ -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.
......
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment