diff --git a/public/modules/custom/helfi_rekry_content/src/Entity/JobListing.php b/public/modules/custom/helfi_rekry_content/src/Entity/JobListing.php index e02a3321..b485353b 100644 --- a/public/modules/custom/helfi_rekry_content/src/Entity/JobListing.php +++ b/public/modules/custom/helfi_rekry_content/src/Entity/JobListing.php @@ -124,12 +124,12 @@ public function getCityDescriptions() : array { /** * Get organization taxonomy term. * - * @return \Drupal\taxonomy\TermInterface|bool + * @return \Drupal\taxonomy\TermInterface|false * Returns the organization taxonomy term or false if not set. * * @throws \Drupal\Core\TypedData\Exception\MissingDataException */ - public function getOrganization() : TermInterface|bool { + public function getOrganization() : TermInterface|FALSE { $organization_id = ''; // Get the organization id from the migrated field. @@ -153,7 +153,8 @@ public function getOrganization() : TermInterface|bool { $organization = $this->entityTypeManager() ->getStorage('taxonomy_term') ->load($organization_id); - return $organization; + + return $organization ?? FALSE; } catch (\Exception $e) { return FALSE; @@ -257,7 +258,10 @@ public function getOrganizationDescription() : FilteredMarkup|string { } // If not and the organization description is empty, // check if the organization taxonomy description is set and use it. - elseif ($organization_description->isEmpty() && !$organization->get('description')->isEmpty()) { + elseif ( + $organization_description->isEmpty() && + $organization && !$organization->get('description')->isEmpty() + ) { $organization_description = $organization->get('description'); }