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

ISTWCMS-4704: adding function to check for featured image

parent f0d25b76
No related branches found
No related tags found
1 merge request!112Feature/istwcms 4704 m26lebla ebremner content types
......@@ -370,6 +370,39 @@ class UWService implements UWServiceInterface {
];
}
/**
* {@inheritDoc}
*/
public function uwCheckNodeForFeaturedImage(Node $node): string {
// Set the node type.
$node_type = $node->getType();
// Get the list of content types that are allowed to have
// feature images from our service.
$featured_image = $this->uwGetFeaturedImageContentTypes();
// If node is allowed to have a featured image, make sure that
// node actually has an image.
if (in_array($node_type, array_keys($featured_image))) {
// Get the field name.
$field_name = $featured_image[$node_type];
// Get the image object values from the node.
$image = $node->$field_name->getValue();
// If there is an image present, set the variable so that
// the page title will not be displayed.
if ($image) {
return 'yes';
}
else {
return 'no';
}
}
}
/**
* {@inheritDoc}
*/
......
......@@ -66,6 +66,17 @@ interface UWServiceInterface {
*/
public function uwGetFeaturedImageContentTypes(): array;
/**
* Gets dates from node.
*
* @param \Drupal\node\Node $node
* Node entity.
*
* @return string
* Yes or no.
*/
public function uwCheckNodeForFeaturedImage(Node $node): string;
/**
* 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