Skip to content

Commit 7e45798

Browse files
committed
IBX-6554: Simplified location path check in LocationVoter for improved clarity and null safety
1 parent 2732fe4 commit 7e45798

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/lib/Menu/Voter/LocationVoter.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,11 @@ public function matchItem(ItemInterface $item): ?bool
3434
$contentView = $request->attributes->get('view');
3535
$locationId = $route['parameters']['locationId'];
3636

37-
if ($contentView instanceof ContentView) {
38-
$location = $contentView->getLocation();
39-
if ($location !== null) {
40-
$path = $location->getPath();
41-
42-
if (in_array($locationId, $path, true)) {
43-
return true;
44-
}
45-
}
37+
if ($contentView instanceof ContentView && in_array(
38+
$locationId,
39+
$contentView->getLocation()->path ?? [$contentView->getLocation()->id]
40+
)) {
41+
return true;
4642
}
4743
}
4844
}

0 commit comments

Comments
 (0)