add regulation list and basic regulation list query

This commit is contained in:
2022-06-16 15:37:51 +02:00
parent 8982697a73
commit da9eba2618
6 changed files with 446 additions and 8 deletions

View File

@@ -11,12 +11,13 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Menu;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Knp\Menu\MenuItem;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
@@ -24,20 +25,20 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/
class SectionMenuBuilder implements LocalMenuBuilderInterface
{
protected AuthorizationCheckerInterface $authorizationChecker;
protected ParameterBagInterface $parameterBag;
protected TranslatorInterface $translator;
private Security $security;
/**
* SectionMenuBuilder constructor.
*/
public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator, ParameterBagInterface $parameterBag)
public function __construct(ParameterBagInterface $parameterBag, Security $security, TranslatorInterface $translator)
{
$this->authorizationChecker = $authorizationChecker;
$this->translator = $translator;
$this->parameterBag = $parameterBag;
$this->security = $security;
$this->translator = $translator;
}
/**
@@ -45,7 +46,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
*/
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
if ($this->authorizationChecker->isGranted(PersonVoter::CREATE) && $this->parameterBag->get('chill_person.create_person_allowed')) {
if ($this->security->isGranted(PersonVoter::CREATE) && $this->parameterBag->get('chill_person.create_person_allowed')) {
$menu->addChild($this->translator->trans('Add a person'), [
'route' => 'chill_person_new',
])
@@ -65,7 +66,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
]);
}
if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) {
if ($this->security->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) {
$menu->addChild($this->translator->trans('reassign.Bulk reassign'), [
'route' => 'chill_course_list_reassign',
])
@@ -74,6 +75,16 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
'icons' => [],
]);
}
if ($this->security->getUser() instanceof User && $this->security->isGranted('ROLE_USER')) {
$menu
->addChild('Régulation', [
'route' => 'chill_person_course_list_regulation',
])
->setExtras([
'order' => 150,
]);
}
}
public static function getMenuIds(): array