diff --git a/src/Service/UWService.php b/src/Service/UWService.php index f96a86956ea79ae9f3011d96c9084871c2b6b51d..54cc7781416f722d961977c3384aa2e51c03be92 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -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} */ diff --git a/src/Service/UWServiceInterface.php b/src/Service/UWServiceInterface.php index 576830ea4660d92a550b403b8693bf3bc89626fa..00ede8c0879086843043f99cda6a834d40cbe33d 100644 --- a/src/Service/UWServiceInterface.php +++ b/src/Service/UWServiceInterface.php @@ -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. *