Skip to content

Commit

Permalink
Merge pull request #1565 from weather-gov/eg-routing-hotfix-2
Browse files Browse the repository at this point in the history
Restoring latest version of WeatherInfoController
  • Loading branch information
eric-gade authored Aug 15, 2024
2 parents 575e196 + 43f0f6a commit 60b42d3
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* Responses for Weather Info node routes
*
*/

final class WeatherInfoController extends ControllerBase
{
/**
Expand Down Expand Up @@ -58,7 +57,7 @@ public function getWFOInfoFromTerm($wfoTerm)
$results = array_values($results);

if (count($results) == 0) {
throw new NotFoundHttpException();
return false;
}
return $results[0];
}
Expand All @@ -70,8 +69,16 @@ public function content($wfo)
try {
$wfoTerm = $this->getWFOTaxonomyTerm($wfo);
$wfoInfo = $this->getWFOInfoFromTerm($wfoTerm);
if (!$wfoInfo) {
// If there's not already a node for this WFO, create a blank
// one in memory so we can still render a page. It'll just have
// less content in it.
$wfoInfo = Node::create(["type" => "wfo_info"]);
$wfoInfo->set("field_wfo", $wfoTerm);
}
$viewBuilder = \Drupal::entityTypeManager()->getViewBuilder("node");
return $viewBuilder->view($wfoInfo);
$build = $viewBuilder->view($wfoInfo);
return $build;
} catch (\Throwable $ex) {
throw new NotFoundHttpException();
}
Expand Down

0 comments on commit 60b42d3

Please sign in to comment.