|
|
@@ -38,12 +38,45 @@ class UrlResolver |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function isInAdminArea(): bool |
|
|
|
public function isRouteAdmin(): bool |
|
|
|
{ |
|
|
|
return $this->testRoute(['admin_', 'file_manager']); |
|
|
|
} |
|
|
|
|
|
|
|
public function isRouteLogin(): bool |
|
|
|
{ |
|
|
|
return $this->testRoute(['sov_login', 'sov_logout', 'frontend_security_login']) ; |
|
|
|
} |
|
|
|
|
|
|
|
public function testRoute($mixed, $route = null): bool |
|
|
|
{ |
|
|
|
if(is_null($route)) { |
|
|
|
$route = $this->getRouteCurrentRequest(); |
|
|
|
} |
|
|
|
|
|
|
|
if(!$route) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if(is_array($mixed)) { |
|
|
|
foreach($mixed as $testRoute) { |
|
|
|
if($this->testRoute($testRoute, $route)) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return strpos($route, $mixed) !== false; |
|
|
|
} |
|
|
|
|
|
|
|
public function getRouteCurrentRequest(): ?string |
|
|
|
{ |
|
|
|
$requestAttributes = $this->requestStack->getCurrentRequest()->attributes->all(); |
|
|
|
$route = isset($requestAttributes['_route']) ? $requestAttributes['_route'] : false; |
|
|
|
$route = isset($requestAttributes['_route']) ? $requestAttributes['_route'] : null; |
|
|
|
|
|
|
|
return $route && (in_array($route, ['sov_login', 'sov_logout']) || strpos($route, 'admin_') !== false) ; |
|
|
|
return $route; |
|
|
|
} |
|
|
|
|
|
|
|
} |