mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
57 lines
1.7 KiB
PHP
57 lines
1.7 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\CalendarBundle\Menu;
|
|
|
|
use Chill\CalendarBundle\Security\Voter\CalendarVoter;
|
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
use Knp\Menu\MenuItem;
|
|
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
use Symfony\Component\Security\Core\Security;
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
|
class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
|
{
|
|
private Security $security;
|
|
|
|
protected TranslatorInterface $translator;
|
|
|
|
public function __construct(
|
|
Security $security,
|
|
TranslatorInterface $translator
|
|
) {
|
|
$this->security = $security;
|
|
$this->translator = $translator;
|
|
}
|
|
|
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
|
{
|
|
$period = $parameters['accompanyingCourse'];
|
|
|
|
if ($this->security->isGranted(CalendarVoter::SEE, $period)) {
|
|
$menu->addChild($this->translator->trans('Calendar'), [
|
|
'route' => 'chill_calendar_calendar_list',
|
|
'routeParameters' => [
|
|
'accompanying_period_id' => $period->getId(),
|
|
], ])
|
|
->setExtras(['order' => 35]);
|
|
}
|
|
}
|
|
|
|
public static function getMenuIds(): array
|
|
{
|
|
return ['accompanyingCourse'];
|
|
}
|
|
}
|