adding budget to person menu

This commit is contained in:
Julie Lenaerts 2022-02-23 14:52:37 +01:00
parent 35aa05fb97
commit 1fdc994c0a
3 changed files with 11 additions and 21 deletions

View File

@ -15,19 +15,14 @@ use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem; use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class UserMenuBuilder implements LocalMenuBuilderInterface class PersonMenuBuilder implements LocalMenuBuilderInterface
{ {
/** protected AuthorizationCheckerInterface $authorizationChecker;
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
/** protected TranslatorInterface $translator;
* @var TranslatorInterface
*/
protected $translator;
public function __construct( public function __construct(
AuthorizationCheckerInterface $authorizationChecker, AuthorizationCheckerInterface $authorizationChecker,
@ -39,10 +34,10 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
public function buildMenu($menuId, MenuItem $menu, array $parameters) public function buildMenu($menuId, MenuItem $menu, array $parameters)
{ {
/** @var \Chill\PersonBundle\Entity\Person $person */ /** @var Person $person */
$person = $parameters['person']; $person = $parameters['person'];
if ($this->authorizationChecker->isGranted(BudgetElementVoter::SHOW, $person)) { // if ($this->authorizationChecker->isGranted(BudgetElementVoter::SHOW, $person)) {
$menu->addChild( $menu->addChild(
$this->translator->trans('Budget'), $this->translator->trans('Budget'),
[ [
@ -50,8 +45,8 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
'routeParameters' => ['id' => $person->getId()], 'routeParameters' => ['id' => $person->getId()],
] ]
) )
->setExtra('order', 460); ->setExtra('order', 4000);
} // }
} }
public static function getMenuIds(): array public static function getMenuIds(): array

View File

@ -1,7 +1,5 @@
services: services:
Chill\BudgetBundle\Menu\UserMenuBuilder: Chill\BudgetBundle\Menu\PersonMenuBuilder:
arguments: autowire: true
$authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
$translator: '@Symfony\Contracts\Translation\TranslatorInterface'
tags: tags:
- { name: 'chill.menu_builder' } - { name: 'chill.menu_builder' }

View File

@ -33,10 +33,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
*/ */
protected $showAccompanyingPeriod; protected $showAccompanyingPeriod;
/** protected TranslatorInterface $translator;
* @var TranslatorInterface
*/
protected $translator;
private Security $security; private Security $security;