Skip to content

Commit

Permalink
Always show elements in the back end
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Apr 5, 2024
1 parent 2480c30 commit 0b694df
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/EventListener/VisibleElementListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace Terminal42\Geoip2CountryBundle\EventListener;

use Contao\CoreBundle\Routing\ScopeMatcher;
use Contao\Model;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Terminal42\Geoip2CountryBundle\CountryProvider;

Expand All @@ -13,11 +15,16 @@ class VisibleElementListener
public function __construct(
private readonly CountryProvider $countryProvider,
private readonly RequestStack $requestStack,
private readonly ScopeMatcher $scopeMatcher,
) {
}

public function __invoke(Model $element, bool $hasAccess): bool
{
if ($this->scopeMatcher->isBackendRequest($this->requestStack->getCurrentRequest() ?? Request::create(''))) {
return $hasAccess;
}

if ('show' !== $element->geoip_visibility && 'hide' !== $element->geoip_visibility) {
return $hasAccess;
}
Expand Down

0 comments on commit 0b694df

Please sign in to comment.