mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-28 21:16:13 +00:00
Rights added to all menu entries
This commit is contained in:
parent
aebb21935b
commit
0ffd6a857c
@ -15,19 +15,13 @@ use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
|||||||
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\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class PersonMenuBuilder 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,
|
||||||
|
@ -16,29 +16,17 @@ 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\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class UserMenuBuilder implements LocalMenuBuilderInterface
|
class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||||
{
|
{
|
||||||
/**
|
public AuthorizationCheckerInterface $authorizationChecker;
|
||||||
* @var AuthorizationCheckerInterface
|
|
||||||
*/
|
|
||||||
public $authorizationChecker;
|
|
||||||
|
|
||||||
/**
|
public CountNotificationTask $counter;
|
||||||
* @var CountNotificationTask
|
|
||||||
*/
|
|
||||||
public $counter;
|
|
||||||
|
|
||||||
/**
|
public TokenStorageInterface $tokenStorage;
|
||||||
* @var TokenStorageInterface
|
|
||||||
*/
|
|
||||||
public $tokenStorage;
|
|
||||||
|
|
||||||
/**
|
public TranslatorInterface $translator;
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
public $translator;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
CountNotificationTask $counter,
|
CountNotificationTask $counter,
|
||||||
|
@ -14,8 +14,10 @@ namespace Chill\CalendarBundle\Menu;
|
|||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
||||||
@ -26,14 +28,18 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
|
|
||||||
protected TranslatorInterface $translator;
|
protected TranslatorInterface $translator;
|
||||||
|
|
||||||
|
protected Security $security;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TokenStorageInterface $tokenStorage,
|
TokenStorageInterface $tokenStorage,
|
||||||
AuthorizationHelper $authorizationHelper,
|
AuthorizationHelper $authorizationHelper,
|
||||||
TranslatorInterface $translator
|
TranslatorInterface $translator,
|
||||||
|
Security $security
|
||||||
) {
|
) {
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
$this->tokenStorage = $tokenStorage;
|
$this->tokenStorage = $tokenStorage;
|
||||||
|
$this->security = $security;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
@ -41,12 +47,15 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
$period = $parameters['accompanyingCourse'];
|
$period = $parameters['accompanyingCourse'];
|
||||||
|
|
||||||
if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep()) {
|
if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep()) {
|
||||||
$menu->addChild($this->translator->trans('Calendar'), [
|
|
||||||
'route' => 'chill_calendar_calendar_list',
|
if ($this->security->isGranted(AccompanyingPeriodVoter::SEE, $period)) {
|
||||||
'routeParameters' => [
|
$menu->addChild($this->translator->trans('Calendar'), [
|
||||||
'accompanying_period_id' => $period->getId(),
|
'route' => 'chill_calendar_calendar_list',
|
||||||
], ])
|
'routeParameters' => [
|
||||||
->setExtras(['order' => 35]);
|
'accompanying_period_id' => $period->getId(),
|
||||||
|
], ])
|
||||||
|
->setExtras(['order' => 35]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,19 +15,13 @@ use Chill\AMLI\FamilyMembersBundle\Security\Voter\FamilyMemberVoter;
|
|||||||
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\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class UserMenuBuilder implements LocalMenuBuilderInterface
|
class UserMenuBuilder 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,
|
||||||
|
@ -12,11 +12,24 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Routing\MenuBuilder;
|
namespace Chill\MainBundle\Routing\MenuBuilder;
|
||||||
|
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
|
|
||||||
class LocationMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface
|
class LocationMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface
|
||||||
{
|
{
|
||||||
|
private AuthorizationCheckerInterface $authorizationChecker;
|
||||||
|
|
||||||
|
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
|
||||||
|
{
|
||||||
|
$this->authorizationChecker = $authorizationChecker;
|
||||||
|
}
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$menu->addChild('Location type list', [
|
$menu->addChild('Location type list', [
|
||||||
'route' => 'chill_crud_main_location_type_index',
|
'route' => 'chill_crud_main_location_type_index',
|
||||||
])->setExtras(['order' => 205]);
|
])->setExtras(['order' => 205]);
|
||||||
|
@ -12,11 +12,23 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Routing\MenuBuilder;
|
namespace Chill\MainBundle\Routing\MenuBuilder;
|
||||||
|
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
|
|
||||||
class PermissionMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface
|
class PermissionMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface
|
||||||
{
|
{
|
||||||
|
private AuthorizationCheckerInterface $authorizationChecker;
|
||||||
|
|
||||||
|
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
|
||||||
|
{
|
||||||
|
$this->authorizationChecker = $authorizationChecker;
|
||||||
|
}
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
|
if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$menu->addChild('Permissions group list', [
|
$menu->addChild('Permissions group list', [
|
||||||
'route' => 'admin_permissionsgroup',
|
'route' => 'admin_permissionsgroup',
|
||||||
])->setExtras([
|
])->setExtras([
|
||||||
|
@ -15,22 +15,17 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|||||||
use Chill\MainBundle\Security\Authorization\ChillExportVoter;
|
use Chill\MainBundle\Security\Authorization\ChillExportVoter;
|
||||||
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\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SectionMenuBuilder.
|
* Class SectionMenuBuilder.
|
||||||
*/
|
*/
|
||||||
class SectionMenuBuilder implements LocalMenuBuilderInterface
|
class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var AuthorizationCheckerInterface
|
|
||||||
*/
|
|
||||||
protected $authorizationChecker;
|
|
||||||
|
|
||||||
/**
|
protected AuthorizationCheckerInterface $authorizationChecker;
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
protected TranslatorInterface $translator;
|
||||||
protected $translator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SectionMenuBuilder constructor.
|
* SectionMenuBuilder constructor.
|
||||||
@ -46,22 +41,26 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
*/
|
*/
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
$menu->addChild($this->translator->trans('Homepage'), [
|
if (!$this->authorizationChecker->isGranted('ROLE_USER')) {
|
||||||
'route' => 'chill_main_homepage',
|
|
||||||
])
|
$menu->addChild($this->translator->trans('Homepage'), [
|
||||||
->setExtras([
|
'route' => 'chill_main_homepage',
|
||||||
'icons' => ['home'],
|
])
|
||||||
'order' => 0,
|
->setExtras([
|
||||||
]);
|
'icons' => ['home'],
|
||||||
|
'order' => 0,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$menu->addChild($this->translator->trans('Global timeline'), [
|
||||||
|
'route' => 'chill_center_timeline',
|
||||||
|
])
|
||||||
|
->setExtras(
|
||||||
|
[
|
||||||
|
'order' => 10,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Global timeline'), [
|
|
||||||
'route' => 'chill_center_timeline',
|
|
||||||
])
|
|
||||||
->setExtras(
|
|
||||||
[
|
|
||||||
'order' => 10,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) {
|
if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) {
|
||||||
$menu->addChild($this->translator->trans('Export Menu'), [
|
$menu->addChild($this->translator->trans('Export Menu'), [
|
||||||
|
@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\User;
|
|||||||
use Chill\MainBundle\Notification\Counter\NotificationByUserCounter;
|
use Chill\MainBundle\Notification\Counter\NotificationByUserCounter;
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Chill\MainBundle\Workflow\Counter\WorkflowByUserCounter;
|
use Chill\MainBundle\Workflow\Counter\WorkflowByUserCounter;
|
||||||
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
@ -28,20 +29,28 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
|
|
||||||
private WorkflowByUserCounter $workflowByUserCounter;
|
private WorkflowByUserCounter $workflowByUserCounter;
|
||||||
|
|
||||||
|
private AuthorizationCheckerInterface $authorizationChecker;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
NotificationByUserCounter $notificationByUserCounter,
|
NotificationByUserCounter $notificationByUserCounter,
|
||||||
WorkflowByUserCounter $workflowByUserCounter,
|
WorkflowByUserCounter $workflowByUserCounter,
|
||||||
Security $security,
|
Security $security,
|
||||||
TranslatorInterface $translator
|
TranslatorInterface $translator,
|
||||||
|
AuthorizationCheckerInterface $authorizationChecker
|
||||||
) {
|
) {
|
||||||
$this->notificationByUserCounter = $notificationByUserCounter;
|
$this->notificationByUserCounter = $notificationByUserCounter;
|
||||||
$this->workflowByUserCounter = $workflowByUserCounter;
|
$this->workflowByUserCounter = $workflowByUserCounter;
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
|
$this->authorizationChecker = $authorizationChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildMenu($menuId, \Knp\Menu\MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, \Knp\Menu\MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
|
if (!$this->authorizationChecker->isGranted('ROLE_USER')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$user = $this->security->getUser();
|
$user = $this->security->getUser();
|
||||||
|
|
||||||
if ($user instanceof User) {
|
if ($user instanceof User) {
|
||||||
|
@ -29,10 +29,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
|
|
||||||
protected Security $security;
|
protected Security $security;
|
||||||
|
|
||||||
/**
|
protected TranslatorInterface $translator;
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
protected $translator;
|
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $translator, Registry $registry, Security $security)
|
public function __construct(TranslatorInterface $translator, Registry $registry, Security $security)
|
||||||
{
|
{
|
||||||
@ -46,12 +43,14 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
/** @var AccompanyingPeriod $period */
|
/** @var AccompanyingPeriod $period */
|
||||||
$period = $parameters['accompanyingCourse'];
|
$period = $parameters['accompanyingCourse'];
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Resume Accompanying Course'), [
|
if ($this->security->isGranted(AccompanyingPeriodVoter::SEE, $period)) {
|
||||||
'route' => 'chill_person_accompanying_course_index',
|
$menu->addChild($this->translator->trans('Resume Accompanying Course'), [
|
||||||
'routeParameters' => [
|
'route' => 'chill_person_accompanying_course_index',
|
||||||
'accompanying_period_id' => $period->getId(),
|
'routeParameters' => [
|
||||||
], ])
|
'accompanying_period_id' => $period->getId(),
|
||||||
->setExtras(['order' => 10]);
|
], ])
|
||||||
|
->setExtras(['order' => 10]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->security->isGranted(AccompanyingPeriodVoter::EDIT, $period)) {
|
if ($this->security->isGranted(AccompanyingPeriodVoter::EDIT, $period)) {
|
||||||
$menu->addChild($this->translator->trans('Edit Accompanying Course'), [
|
$menu->addChild($this->translator->trans('Edit Accompanying Course'), [
|
||||||
@ -94,22 +93,25 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
|
|
||||||
$workflow = $this->registry->get($period, 'accompanying_period_lifecycle');
|
$workflow = $this->registry->get($period, 'accompanying_period_lifecycle');
|
||||||
|
|
||||||
if (null !== $period->getClosingDate()) {
|
if ($this->security->isGranted(AccompanyingPeriodVoter::EDIT, $period)) {
|
||||||
$menu->addChild($this->translator->trans('Re-open accompanying course'), [
|
|
||||||
'route' => 'chill_person_accompanying_course_reopen',
|
|
||||||
'routeParameters' => [
|
|
||||||
'accompanying_period_id' => $period->getId(),
|
|
||||||
], ])
|
|
||||||
->setExtras(['order' => 99998]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($workflow->can($period, 'close')) {
|
if (null !== $period->getClosingDate()) {
|
||||||
$menu->addChild($this->translator->trans('Close Accompanying Course'), [
|
$menu->addChild($this->translator->trans('Re-open accompanying course'), [
|
||||||
'route' => 'chill_person_accompanying_course_close',
|
'route' => 'chill_person_accompanying_course_reopen',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'accompanying_period_id' => $period->getId(),
|
'accompanying_period_id' => $period->getId(),
|
||||||
], ])
|
], ])
|
||||||
->setExtras(['order' => 99999]);
|
->setExtras(['order' => 99998]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($workflow->can($period, 'close')) {
|
||||||
|
$menu->addChild($this->translator->trans('Close Accompanying Course'), [
|
||||||
|
'route' => 'chill_person_accompanying_course_close',
|
||||||
|
'routeParameters' => [
|
||||||
|
'accompanying_period_id' => $period->getId(),
|
||||||
|
], ])
|
||||||
|
->setExtras(['order' => 99999]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,9 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Menu;
|
namespace Chill\PersonBundle\Menu;
|
||||||
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class HouseholdMenuBuilder implements LocalMenuBuilderInterface
|
class HouseholdMenuBuilder implements LocalMenuBuilderInterface
|
||||||
@ -22,9 +24,12 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
*/
|
*/
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $translator)
|
private $security;
|
||||||
|
|
||||||
|
public function __construct(TranslatorInterface $translator, Security $security)
|
||||||
{
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
|
$this->security = $security;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
|
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
|
||||||
@ -32,40 +37,47 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
/** @var \Chill\PersonBundle\Entity\Household\Household $household */
|
/** @var \Chill\PersonBundle\Entity\Household\Household $household */
|
||||||
$household = $parameters['household'];
|
$household = $parameters['household'];
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household.Household summary'), [
|
if ($this->security->isGranted(HouseholdVoter::SEE, $household)) {
|
||||||
'route' => 'chill_person_household_summary',
|
$menu->addChild($this->translator->trans('household.Household summary'), [
|
||||||
'routeParameters' => [
|
'route' => 'chill_person_household_summary',
|
||||||
'household_id' => $household->getId(),
|
'routeParameters' => [
|
||||||
], ])
|
'household_id' => $household->getId(),
|
||||||
->setExtras(['order' => 10]);
|
], ])
|
||||||
|
->setExtras(['order' => 10]);
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household.Relationship'), [
|
$menu->addChild($this->translator->trans('household.Relationship'), [
|
||||||
'route' => 'chill_person_household_relationship',
|
'route' => 'chill_person_household_relationship',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'household_id' => $household->getId(),
|
'household_id' => $household->getId(),
|
||||||
], ])
|
], ])
|
||||||
->setExtras(['order' => 15]);
|
->setExtras(['order' => 15]);
|
||||||
|
}
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household_composition.Compositions'), [
|
if ($this->security->isGranted(HouseholdVoter::EDIT, $household)) {
|
||||||
'route' => 'chill_person_household_composition_index',
|
$menu->addChild($this->translator->trans('household_composition.Compositions'), [
|
||||||
'routeParameters' => [
|
'route' => 'chill_person_household_composition_index',
|
||||||
'id' => $household->getId(),
|
'routeParameters' => [
|
||||||
], ])
|
'id' => $household->getId(),
|
||||||
->setExtras(['order' => 17]);
|
], ])
|
||||||
|
->setExtras(['order' => 17]);
|
||||||
|
}
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household.Accompanying period'), [
|
if ($this->security->isGranted(HouseholdVoter::SEE, $household)) {
|
||||||
'route' => 'chill_person_household_accompanying_period',
|
$menu->addChild($this->translator->trans('household.Accompanying period'), [
|
||||||
'routeParameters' => [
|
'route' => 'chill_person_household_accompanying_period',
|
||||||
'household_id' => $household->getId(),
|
'routeParameters' => [
|
||||||
], ])
|
'household_id' => $household->getId(),
|
||||||
->setExtras(['order' => 20]);
|
], ])
|
||||||
|
->setExtras(['order' => 20]);
|
||||||
|
|
||||||
|
$menu->addChild($this->translator->trans('household.Addresses'), [
|
||||||
|
'route' => 'chill_person_household_addresses',
|
||||||
|
'routeParameters' => [
|
||||||
|
'household_id' => $household->getId(),
|
||||||
|
], ])
|
||||||
|
->setExtras(['order' => 30]);
|
||||||
|
}
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household.Addresses'), [
|
|
||||||
'route' => 'chill_person_household_addresses',
|
|
||||||
'routeParameters' => [
|
|
||||||
'household_id' => $household->getId(),
|
|
||||||
], ])
|
|
||||||
->setExtras(['order' => 30]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
public static function getMenuIds(): array
|
||||||
|
@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Menu;
|
|||||||
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
@ -33,10 +34,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
*/
|
*/
|
||||||
protected $showAccompanyingPeriod;
|
protected $showAccompanyingPeriod;
|
||||||
|
|
||||||
/**
|
protected TranslatorInterface $translator;
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
protected $translator;
|
|
||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
@ -52,45 +50,47 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
$menu->addChild($this->translator->trans('Person details'), [
|
if ($this->security->isGranted(PersonVoter::SEE, $parameters['person'])) {
|
||||||
'route' => 'chill_person_view',
|
|
||||||
'routeParameters' => [
|
|
||||||
'person_id' => $parameters['person']->getId(),
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->setExtras([
|
|
||||||
'order' => 50,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Residential addresses'), [
|
$menu->addChild($this->translator->trans('Person details'), [
|
||||||
'route' => 'chill_person_residential_address_list',
|
'route' => 'chill_person_view',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'id' => $parameters['person']->getId(),
|
'person_id' => $parameters['person']->getId(),
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->setExtras([
|
->setExtras([
|
||||||
'order' => 60,
|
'order' => 50,
|
||||||
]);
|
]);
|
||||||
|
$menu->addChild($this->translator->trans('Residential addresses'), [
|
||||||
|
'route' => 'chill_person_residential_address_list',
|
||||||
|
'routeParameters' => [
|
||||||
|
'id' => $parameters['person']->getId(),
|
||||||
|
],
|
||||||
|
])
|
||||||
|
->setExtras([
|
||||||
|
'order' => 60,
|
||||||
|
]);
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household.person history'), [
|
$menu->addChild($this->translator->trans('household.person history'), [
|
||||||
'route' => 'chill_person_household_person_history',
|
'route' => 'chill_person_household_person_history',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'person_id' => $parameters['person']->getId(),
|
'person_id' => $parameters['person']->getId(),
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->setExtras([
|
->setExtras([
|
||||||
'order' => 99999,
|
'order' => 99999,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Person duplicate'), [
|
$menu->addChild($this->translator->trans('Person duplicate'), [
|
||||||
'route' => 'chill_person_duplicate_view',
|
'route' => 'chill_person_duplicate_view',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'person_id' => $parameters['person']->getId(),
|
'person_id' => $parameters['person']->getId(),
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->setExtras([
|
->setExtras([
|
||||||
'order' => 99999,
|
'order' => 99999,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
'visible' === $this->showAccompanyingPeriod
|
'visible' === $this->showAccompanyingPeriod
|
||||||
@ -106,16 +106,17 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'order' => 100,
|
'order' => 100,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
if ($this->security->isGranted(PersonVoter::SEE, $parameters['person'])) {
|
||||||
$menu->addChild($this->translator->trans('person_resources_menu'), [
|
$menu->addChild($this->translator->trans('person_resources_menu'), [
|
||||||
'route' => 'chill_person_resource_list',
|
'route' => 'chill_person_resource_list',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'person_id' => $parameters['person']->getId(),
|
'person_id' => $parameters['person']->getId(),
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->setExtras([
|
->setExtras([
|
||||||
'order' => 99999,
|
'order' => 99999,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
public static function getMenuIds(): array
|
||||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Menu;
|
namespace Chill\PersonBundle\Menu;
|
||||||
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
@ -56,13 +57,15 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Create an accompanying course'), [
|
if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::CREATE)) {
|
||||||
'route' => 'chill_person_accompanying_course_new',
|
$menu->addChild($this->translator->trans('Create an accompanying course'), [
|
||||||
])
|
'route' => 'chill_person_accompanying_course_new',
|
||||||
->setExtras([
|
])
|
||||||
'order' => 11,
|
->setExtras([
|
||||||
'icons' => ['plus'],
|
'order' => 11,
|
||||||
]);
|
'icons' => ['plus'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
public static function getMenuIds(): array
|
||||||
|
@ -16,19 +16,13 @@ use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
|||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class MenuBuilder implements LocalMenuBuilderInterface
|
class MenuBuilder 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,
|
||||||
@ -38,22 +32,6 @@ class MenuBuilder implements LocalMenuBuilderInterface
|
|||||||
$this->authorizationChecker = $authorizationChecker;
|
$this->authorizationChecker = $authorizationChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildAccompanyingCourseMenu($menu, $parameters)
|
|
||||||
{
|
|
||||||
$course = $parameters['accompanyingCourse'];
|
|
||||||
|
|
||||||
if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) {
|
|
||||||
$menu->addChild(
|
|
||||||
$this->translator->trans('Tasks'),
|
|
||||||
[
|
|
||||||
'route' => 'chill_task_singletask_by-course_list',
|
|
||||||
'routeParameters' => ['id' => $course->getId()],
|
|
||||||
]
|
|
||||||
)
|
|
||||||
->setExtra('order', 400);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
switch ($menuId) {
|
switch ($menuId) {
|
||||||
@ -77,6 +55,22 @@ class MenuBuilder implements LocalMenuBuilderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function buildAccompanyingCourseMenu($menu, $parameters)
|
||||||
|
{
|
||||||
|
$course = $parameters['accompanyingCourse'];
|
||||||
|
|
||||||
|
if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) {
|
||||||
|
$menu->addChild(
|
||||||
|
$this->translator->trans('Tasks'),
|
||||||
|
[
|
||||||
|
'route' => 'chill_task_singletask_by-course_list',
|
||||||
|
'routeParameters' => ['id' => $course->getId()],
|
||||||
|
]
|
||||||
|
)
|
||||||
|
->setExtra('order', 400);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function buildPersonMenu($menu, $parameters)
|
public function buildPersonMenu($menu, $parameters)
|
||||||
{
|
{
|
||||||
//var $person \Chill\PersonBundle\Entity\Person */
|
//var $person \Chill\PersonBundle\Entity\Person */
|
||||||
|
@ -15,19 +15,13 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|||||||
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
||||||
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\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class SectionMenuBuilder implements LocalMenuBuilderInterface
|
class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||||
{
|
{
|
||||||
/**
|
public AuthorizationCheckerInterface $authorizationChecker;
|
||||||
* @var AuthorizationCheckerInterface
|
|
||||||
*/
|
|
||||||
public $authorizationChecker;
|
|
||||||
|
|
||||||
/**
|
public TranslatorInterface $translator;
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
public $translator;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AuthorizationCheckerInterface $authorizationChecker,
|
AuthorizationCheckerInterface $authorizationChecker,
|
||||||
|
@ -17,29 +17,18 @@ 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\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class UserMenuBuilder implements LocalMenuBuilderInterface
|
class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var AuthorizationCheckerInterface
|
|
||||||
*/
|
|
||||||
public $authorizationChecker;
|
|
||||||
|
|
||||||
/**
|
public AuthorizationCheckerInterface $authorizationChecker;
|
||||||
* @var CountNotificationTask
|
|
||||||
*/
|
|
||||||
public $counter;
|
|
||||||
|
|
||||||
/**
|
public CountNotificationTask $counter;
|
||||||
* @var TokenStorageInterface
|
|
||||||
*/
|
|
||||||
public $tokenStorage;
|
|
||||||
|
|
||||||
/**
|
public TokenStorageInterface $tokenStorage;
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
public TranslatorInterface $translator;
|
||||||
public $translator;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
CountNotificationTask $counter,
|
CountNotificationTask $counter,
|
||||||
|
@ -15,22 +15,16 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|||||||
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
||||||
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\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an entry in section to go to third party index page.
|
* Add an entry in section to go to third party index page.
|
||||||
*/
|
*/
|
||||||
class MenuBuilder implements LocalMenuBuilderInterface
|
class MenuBuilder 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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user