Skip to content

Commit

Permalink
Prevent unnecessary country check for navigation templates
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jul 2, 2021
1 parent 56f8224 commit 8e303b4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/EventListener/NavigationTemplateListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __invoke(Template $template): void
return;
}

$country = $this->countryProvider->getCountryCode($this->requestStack->getMasterRequest());
$country = null;

foreach ($items as $k => $item) {
$visibility = $item['geoip_visibility'] ?? null;
Expand All @@ -35,6 +35,10 @@ public function __invoke(Template $template): void
continue;
}

if (null === $country) {
$country = $this->countryProvider->getCountryCode($this->requestStack->getMasterRequest());
}

$countries = array_map('strtoupper', explode(',', $countries));

if (\in_array($country, $countries, true) !== ('show' === $visibility)) {
Expand Down

0 comments on commit 8e303b4

Please sign in to comment.