rdv: add calendar list in menu

This commit is contained in:
nobohan 2021-08-16 10:20:01 +02:00
parent b106a03534
commit 95b50f2b99
2 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,47 @@
<?php
namespace Chill\CalendarBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
{
protected TokenStorageInterface $tokenStorage;
protected AuthorizationHelper $authorizationHelper;
protected TranslatorInterface $translator;
public function __construct(
TokenStorageInterface $tokenStorage,
AuthorizationHelper $authorizationHelper,
TranslatorInterface $translator
) {
$this->translator = $translator;
$this->authorizationHelper = $authorizationHelper;
$this->tokenStorage = $tokenStorage;
}
public static function getMenuIds(): array
{
return ['accompanyingCourse'];
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
$period = $parameters['accompanyingCourse'];
if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep()) {
$menu->addChild($this->translator->trans('Calendar list'), [
'route' => 'chill_calendar_calendar',
'routeParameters' => [
'accompanying_period_id' => $period->getId(),
]])
->setExtras(['order' => 41]);
}
}
}

View File

@ -6,3 +6,9 @@ services:
resource: '../../Repository/'
tags:
- { name: 'doctrine.repository_service' }
Chill\CalendarBundle\Menu\:
autowire: true
autoconfigure: true
resource: '../../Menu/'
tags: ['chill.menu_builder']