mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-30 17:48:07 +00:00
- Added `Security` service to `SectionMenuBuilder` for access control. - Display "Tickets" menu item only if the user has `TicketVoter::READ` permission.
36 lines
943 B
PHP
36 lines
943 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\TicketBundle\Menu;
|
|
|
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|
use Chill\TicketBundle\Security\Voter\TicketVoter;
|
|
use Knp\Menu\MenuItem;
|
|
use Symfony\Component\Security\Core\Security;
|
|
|
|
final readonly class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|
{
|
|
public function __construct(private Security $security) {}
|
|
|
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
|
{
|
|
if ($this->security->isGranted(TicketVoter::READ)) {
|
|
$menu->addChild('Tickets', ['route' => 'chill_ticket_ticket_list'])
|
|
->setExtras(['order' => 250]);
|
|
}
|
|
}
|
|
|
|
public static function getMenuIds(): array
|
|
{
|
|
return ['section'];
|
|
}
|
|
}
|