Skip to content

Commit

Permalink
HPC-9104: Add fail-safe before trying to access a subpage parent entity
Browse files Browse the repository at this point in the history
  • Loading branch information
berliner committed Oct 19, 2023
1 parent 25d2938 commit 48a5b64
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions html/modules/custom/ghi_search/ghi_search.module
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ function ghi_search_node_view(array &$build, EntityInterface $entity, EntityView
if ($view_mode != 'search_result') {
return;
}
if ($entity instanceof SubpageNodeInterface) {
$parent = $entity->getParentNode();
if ($entity instanceof SubpageNodeInterface && $parent = $entity->getParentNode()) {
$build['title'][0]['#context']['value'] = $parent->getTitle() . ': ' . $entity->label();
$build['field_entity_reference']['#access'] = FALSE;
$build['tags'] = $parent->field_tags->view('search_result');
Expand Down

0 comments on commit 48a5b64

Please sign in to comment.