diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index ff34aaf45..3efae86e9 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -29,6 +29,7 @@ use Symfony\Component\Form\Form; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -182,6 +183,27 @@ class CalendarController extends AbstractController ]); } + /** + * @Route("/{_locale}/calendar/calendar/my", name="chill_calendar_calendar_list_my") + * + * @param Request $request + * @return Response + */ + public function myCalendar(Request $request): Response + { + $this->denyAccessUnlessGranted('ROLE_USER'); + + if (!$this->getUser() instanceof User) { + throw new UnauthorizedHttpException('you are not an user'); + } + + $view = '@ChillCalendar/Calendar/listByUser.html.twig'; + + return $this->render($view, [ + 'user' => $this->getUser(), + ]); + } + /** * Lists all Calendar entities. * @@ -193,6 +215,8 @@ class CalendarController extends AbstractController [$user, $accompanyingPeriod] = $this->getEntity($request); + /* + dead code ? if ($user instanceof User) { $calendarItems = $this->calendarRepository->findByUser($user); @@ -203,6 +227,7 @@ class CalendarController extends AbstractController 'user' => $user, ]); } + */ if ($accompanyingPeriod instanceof AccompanyingPeriod) { $total = $this->calendarRepository->countByAccompanyingPeriod($accompanyingPeriod); diff --git a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php index 74512eda5..4049e7c55 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php @@ -58,7 +58,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface if ($this->authorizationChecker->isGranted('ROLE_USER')) { $menu->addChild('My calendar list', [ - 'route' => 'chill_calendar_calendar_list', + 'route' => 'chill_calendar_calendar_list_my', ]) ->setExtras([ 'order' => 9,