*/ namespace Lc\SovBundle\Resolver; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\RequestStack; class UrlResolver { protected ParameterBagInterface $parameterBag; protected RequestStack $requestStack; public function __construct(ParameterBagInterface $parameterBag, RequestStack $requestStack) { $this->parameterBag = $parameterBag; $this->requestStack = $requestStack; } public function isServerLocalhost(): bool { return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']); } public function isBot(): bool { if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match( '/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'] )) { return true; } else { return false; } } public function isInAdminArea(): bool { $requestAttributes = $this->requestStack->getCurrentRequest()->attributes->all(); $route = isset($requestAttributes['_route']) ? $requestAttributes['_route'] : false; return $route && (in_array($route, ['sov_login', 'sov_logout']) || strpos($route, 'admin_') !== false) ; } }