diff --git a/docroot/modules/custom/foia_cfo/src/Controller/CFOController.php b/docroot/modules/custom/foia_cfo/src/Controller/CFOController.php index 336b33d29..48963d13c 100644 --- a/docroot/modules/custom/foia_cfo/src/Controller/CFOController.php +++ b/docroot/modules/custom/foia_cfo/src/Controller/CFOController.php @@ -80,7 +80,10 @@ public function getCouncil(): CacheableJsonResponse { // Title and body of the Council node. $response['title'] = $council_node->label(); - if ($council_node->get('body')) { + if ( + !empty($council_node->get('body')) + && !empty($council_node->get('body')->getValue()[0]['value']) + ) { $body = \Drupal::service('foia_cfo.default')->absolutePathFormatter($council_node->get('body')->getValue()[0]['value']); $response['body'] = $body; } @@ -279,10 +282,10 @@ public function getCommittees(): CacheableJsonResponse { * @param \Drupal\node\Entity\Node $committee * Node object of the committee passed as argument through routing. * - * @return \Drupal\Core\Cache\CacheableJsonResponse|false + * @return \Drupal\Core\Cache\CacheableJsonResponse * Returns json object or false if the node did not load. */ - public function getCommittee(Node $committee) { + public function getCommittee(Node $committee): CacheableJsonResponse { if (!empty($committee) && $committee->isPublished()) { @@ -296,7 +299,11 @@ public function getCommittee(Node $committee) { ]; // Add body HTML if any - use absolute links. - if ($committee->hasField('body') && !empty($committee->get('body'))) { + if ( + $committee->hasField('body') + && !empty($committee->get('body')) + && !empty($committee->get('body')->getValue()[0]['value']) + ) { $response['committee_body'] = \Drupal::service('foia_cfo.default')->absolutePathFormatter($committee->get('body')->getValue()[0]['value']); } @@ -319,7 +326,7 @@ public function getCommittee(Node $committee) { else { // Not a valid committee or not published. - return FALSE; + return new CacheableJsonResponse([]); } diff --git a/docroot/modules/custom/foia_cfo/src/Controller/CFOMeetingsController.php b/docroot/modules/custom/foia_cfo/src/Controller/CFOMeetingsController.php index 8b84692cc..0bf50a3ee 100644 --- a/docroot/modules/custom/foia_cfo/src/Controller/CFOMeetingsController.php +++ b/docroot/modules/custom/foia_cfo/src/Controller/CFOMeetingsController.php @@ -120,10 +120,10 @@ public function getMeetings(): CacheableJsonResponse { * @param \Drupal\node\Entity\Node $meeting * Node object of the meeting passed as argument through routing. * - * @return \Drupal\Core\Cache\CacheableJsonResponse|false + * @return \Drupal\Core\Cache\CacheableJsonResponse * Returns json object or false if the node did not load. */ - public function getMeeting(Node $meeting) { + public function getMeeting(Node $meeting): CacheableJsonResponse { if (!empty($meeting) && $meeting->isPublished()) { @@ -221,7 +221,7 @@ public function getMeeting(Node $meeting) { else { // Not a valid meeting or not published. - return FALSE; + return new CacheableJsonResponse([]); }