mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
116 lines
3.3 KiB
PHP
116 lines
3.3 KiB
PHP
<?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.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\PersonBundle\Menu;
|
|
|
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
|
use Knp\Menu\MenuItem;
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
use Symfony\Component\Security\Core\Security;
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
|
/**
|
|
* Add menu entrie to person menu.
|
|
*
|
|
* Menu entries added :
|
|
*
|
|
* - person details ;
|
|
* - accompanying period (if `visible`)
|
|
*/
|
|
class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|
{
|
|
/**
|
|
* @var string 'visible' or 'hidden'
|
|
*/
|
|
protected $showAccompanyingPeriod;
|
|
|
|
/**
|
|
* @var TranslatorInterface
|
|
*/
|
|
protected $translator;
|
|
|
|
private Security $security;
|
|
|
|
public function __construct(
|
|
ParameterBagInterface $parameterBag,
|
|
Security $security,
|
|
TranslatorInterface $translator
|
|
) {
|
|
$this->showAccompanyingPeriod = $parameterBag->get('chill_person.accompanying_period');
|
|
$this->security = $security;
|
|
$this->translator = $translator;
|
|
}
|
|
|
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
|
{
|
|
$menu->addChild($this->translator->trans('Person details'), [
|
|
'route' => 'chill_person_view',
|
|
'routeParameters' => [
|
|
'person_id' => $parameters['person']->getId(),
|
|
],
|
|
])
|
|
->setExtras([
|
|
'order' => 50,
|
|
]);
|
|
|
|
$menu->addChild($this->translator->trans('household.person history'), [
|
|
'route' => 'chill_person_household_person_history',
|
|
'routeParameters' => [
|
|
'person_id' => $parameters['person']->getId(),
|
|
],
|
|
])
|
|
->setExtras([
|
|
'order' => 99999,
|
|
]);
|
|
|
|
$menu->addChild($this->translator->trans('Person duplicate'), [
|
|
'route' => 'chill_person_duplicate_view',
|
|
'routeParameters' => [
|
|
'person_id' => $parameters['person']->getId(),
|
|
],
|
|
])
|
|
->setExtras([
|
|
'order' => 99999,
|
|
]);
|
|
|
|
if (
|
|
'visible' === $this->showAccompanyingPeriod
|
|
&& $this->security->isGranted(AccompanyingPeriodVoter::SEE, $parameters['person'])
|
|
) {
|
|
$menu->addChild($this->translator->trans('Accompanying period list'), [
|
|
'route' => 'chill_person_accompanying_period_list',
|
|
'routeParameters' => [
|
|
'person_id' => $parameters['person']->getId(),
|
|
],
|
|
])
|
|
->setExtras([
|
|
'order' => 100,
|
|
]);
|
|
}
|
|
|
|
$menu->addChild($this->translator->trans('person_resources_menu'), [
|
|
'route' => 'chill_person_resource_list',
|
|
'routeParameters' => [
|
|
'person_id' => $parameters['person']->getId(),
|
|
],
|
|
])
|
|
->setExtras([
|
|
'order' => 99999,
|
|
]);
|
|
}
|
|
|
|
public static function getMenuIds(): array
|
|
{
|
|
return ['person'];
|
|
}
|
|
}
|