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

View File

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

View File

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