mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
DX: [calendar] simplify menu builder injection deps
This commit is contained in:
parent
2c5fa82380
commit
c04e408d9d
@ -12,51 +12,27 @@ declare(strict_types=1);
|
|||||||
namespace Chill\CalendarBundle\Menu;
|
namespace Chill\CalendarBundle\Menu;
|
||||||
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Chill\TaskBundle\Templating\UI\CountNotificationTask;
|
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class UserMenuBuilder implements LocalMenuBuilderInterface
|
class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||||
{
|
{
|
||||||
/**
|
public TranslatorInterface $translator;
|
||||||
* @var AuthorizationCheckerInterface
|
|
||||||
*/
|
|
||||||
public $authorizationChecker;
|
|
||||||
|
|
||||||
/**
|
private Security $security;
|
||||||
* @var CountNotificationTask
|
|
||||||
*/
|
|
||||||
public $counter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TokenStorageInterface
|
|
||||||
*/
|
|
||||||
public $tokenStorage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
public $translator;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
CountNotificationTask $counter,
|
Security $security,
|
||||||
TokenStorageInterface $tokenStorage,
|
TranslatorInterface $translator
|
||||||
TranslatorInterface $translator,
|
|
||||||
AuthorizationCheckerInterface $authorizationChecker
|
|
||||||
) {
|
) {
|
||||||
$this->counter = $counter;
|
$this->security = $security;
|
||||||
$this->tokenStorage = $tokenStorage;
|
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->authorizationChecker = $authorizationChecker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
$user = $this->tokenStorage->getToken()->getUser();
|
if ($this->security->isGranted('ROLE_USER')) {
|
||||||
|
|
||||||
if ($this->authorizationChecker->isGranted('ROLE_USER')) {
|
|
||||||
$menu->addChild('My calendar list', [
|
$menu->addChild('My calendar list', [
|
||||||
'route' => 'chill_calendar_calendar_list_my',
|
'route' => 'chill_calendar_calendar_list_my',
|
||||||
])
|
])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user