Parcourir la source

UrlResolver : ajout méthode isInAdminArea()

develop
Guillaume il y a 3 ans
Parent
révision
163e019772
1 fichiers modifiés avec 12 ajouts et 1 suppressions
  1. +12
    -1
      Resolver/UrlResolver.php

+ 12
- 1
Resolver/UrlResolver.php Voir le fichier

@@ -8,14 +8,17 @@ 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)
public function __construct(ParameterBagInterface $parameterBag, RequestStack $requestStack)
{
$this->parameterBag = $parameterBag;
$this->requestStack = $requestStack;
}

public function isServerLocalhost(): bool
@@ -35,4 +38,12 @@ class UrlResolver
}
}

public function isInAdminArea(): bool
{
$requestAttributes = $this->requestStack->getCurrentRequest()->attributes->all();
$route = isset($requestAttributes['_route']) ? $requestAttributes['_route'] : false;

return $route && ($route == 'easyadmin' || strpos($route, 'admin_') !== false) ;
}

}

Chargement…
Annuler
Enregistrer