reactive my calendar on new route

This commit is contained in:
Julien Fastré 2022-04-29 23:59:32 +02:00
parent 3fb3df9db1
commit aecdfa6b12
2 changed files with 26 additions and 1 deletions

View File

@ -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);

View File

@ -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,