From 2bae684df986fd0df8e0a60d680b9ea34ac9f049 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 20 May 2021 17:08:47 +0200 Subject: [PATCH] Add list of activities in AccompanyingCourse Menu --- .../Controller/ActivityController.php | 8 ++++++++ .../Menu/AccompanyingCourseMenuBuilder.php | 18 ++++++++++++------ .../config/services/menu.yaml | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 4ae8fe7d0..417c04909 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -311,6 +311,10 @@ class ActivityController extends AbstractController $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); */ + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + return $this->render($view, array( 'entity' => $entity, 'edit_form' => $form->createView(), @@ -379,6 +383,10 @@ class ActivityController extends AbstractController } } + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + return $this->render($view, array( 'activity' => $activity, 'delete_form' => $form->createView(), diff --git a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php index ba0672bb0..402df733b 100644 --- a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -2,16 +2,12 @@ namespace Chill\ActivityBundle\Menu; -use Chill\ActivityBundle\Security\Authorization\ActivityVoter; 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\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; - class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { protected TokenStorageInterface $tokenStorage; @@ -38,11 +34,21 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { $period = $parameters['accompanyingCourse']; + $menu->addChild($this->translator->trans('List of activities'), [ + 'route' => 'chill_activity_activity_list', + 'routeParameters' => [ + 'accompanying_period_id' => $period->getId(), + ]]) + ->setExtras(['order' => 40]); + $menu->addChild($this->translator->trans('Add a new activity'), [ 'route' => 'chill_activity_activity_select_type', 'routeParameters' => [ - 'accompanying_period_id' => $period->getId() + 'accompanying_period_id' => $period->getId(), ]]) - ->setExtras(['order' => 40]); + ->setExtras(['order' => 41]); + + + } } diff --git a/src/Bundle/ChillActivityBundle/config/services/menu.yaml b/src/Bundle/ChillActivityBundle/config/services/menu.yaml index 8e60d3b2e..1c7813799 100644 --- a/src/Bundle/ChillActivityBundle/config/services/menu.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/menu.yaml @@ -12,5 +12,6 @@ services: $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' $translator: '@Symfony\Contracts\Translation\TranslatorInterface' + $entityManager: '@Doctrine\ORM\EntityManagerInterface' tags: - { name: 'chill.menu_builder' }