mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* @see https://www.champs-libres.coop/
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\AMLI\BudgetBundle\Menu;
|
|
|
|
use Chill\AMLI\BudgetBundle\Security\Authorization\BudgetElementVoter;
|
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|
use Knp\Menu\MenuItem;
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
|
use Symfony\Component\Translation\TranslatorInterface;
|
|
|
|
class UserMenuBuilder implements LocalMenuBuilderInterface
|
|
{
|
|
/**
|
|
* @var AuthorizationCheckerInterface
|
|
*/
|
|
protected $authorizationChecker;
|
|
|
|
/**
|
|
* @var TranslatorInterface
|
|
*/
|
|
protected $translator;
|
|
|
|
public function __construct(
|
|
AuthorizationCheckerInterface $authorizationChecker,
|
|
TranslatorInterface $translator
|
|
) {
|
|
$this->authorizationChecker = $authorizationChecker;
|
|
$this->translator = $translator;
|
|
}
|
|
|
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
|
{
|
|
/** @var \Chill\PersonBundle\Entity\Person $person */
|
|
$person = $parameters['person'];
|
|
|
|
if ($this->authorizationChecker->isGranted(BudgetElementVoter::SHOW, $person)) {
|
|
$menu->addChild(
|
|
$this->translator->trans('Budget'),
|
|
[
|
|
'route' => 'chill_budget_elements_index',
|
|
'routeParameters' => ['id' => $person->getId()],
|
|
]
|
|
)
|
|
->setExtra('order', 460);
|
|
}
|
|
}
|
|
|
|
public static function getMenuIds(): array
|
|
{
|
|
return ['person'];
|
|
}
|
|
}
|