mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 13:03:50 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,19 +1,27 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\Menu;
|
||||
|
||||
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
use LogicException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class MenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
private Security $security;
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(
|
||||
Security $security,
|
||||
@@ -23,57 +31,61 @@ final class MenuBuilder implements LocalMenuBuilderInterface
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
switch($menuId) {
|
||||
switch ($menuId) {
|
||||
case 'accompanyingCourse':
|
||||
$this->buildMenuAccompanyingCourse($menu, $parameters);
|
||||
|
||||
break;
|
||||
|
||||
case 'person':
|
||||
$this->buildMenuPerson($menu, $parameters);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \LogicException("this menuid $menuId is not implemented");
|
||||
throw new LogicException("this menuid {$menuId} is not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
protected function buildMenuPerson(MenuItem $menu, array $parameters)
|
||||
public static function getMenuIds(): array
|
||||
{
|
||||
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||
$person = $parameters['person'];
|
||||
|
||||
if ($this->security->isGranted(PersonDocumentVoter::SEE, $person)) {
|
||||
$menu->addChild($this->translator->trans('Documents'), [
|
||||
'route' => 'person_document_index',
|
||||
'routeParameters' => [
|
||||
'person' => $person->getId()
|
||||
]
|
||||
])
|
||||
->setExtras([
|
||||
'order'=> 350
|
||||
]);
|
||||
}
|
||||
return ['person', 'accompanyingCourse'];
|
||||
}
|
||||
|
||||
protected function buildMenuAccompanyingCourse(MenuItem $menu, array $parameters){
|
||||
private function buildMenuAccompanyingCourse(MenuItem $menu, array $parameters)
|
||||
{
|
||||
$course = $parameters['accompanyingCourse'];
|
||||
|
||||
if ($this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $course)) {
|
||||
$menu->addChild($this->translator->trans('Documents'), [
|
||||
'route' => 'accompanying_course_document_index',
|
||||
'routeParameters' => [
|
||||
'course' => $course->getId()
|
||||
]
|
||||
'course' => $course->getId(),
|
||||
],
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 400
|
||||
'order' => 400,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
private function buildMenuPerson(MenuItem $menu, array $parameters)
|
||||
{
|
||||
return [ 'person', 'accompanyingCourse' ];
|
||||
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||
$person = $parameters['person'];
|
||||
|
||||
if ($this->security->isGranted(PersonDocumentVoter::SEE, $person)) {
|
||||
$menu->addChild($this->translator->trans('Documents'), [
|
||||
'route' => 'person_document_index',
|
||||
'routeParameters' => [
|
||||
'person' => $person->getId(),
|
||||
],
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 350,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user