- public function add(Request $request, Registry $doctrine, EntityManagerInterface $manager) {
- //Prevent non-guest to access here
- $this->denyAccessUnlessGranted('ROLE_GUEST', null, $this->translator->trans('Unable to access this page without role %role%!', ['%role%' => $this->translator->trans('Guest')]));
+ public function add(Request $request) {
+ //Without guest role
+ if (!$this->checker->isGranted('ROLE_GUEST')) {
+ //Throw 403
+ throw $this->createAccessDeniedException($this->translator->trans('Unable to access this page without role %role%!', ['%role%' => $this->translator->trans('Guest')]));
+ }
+
+ //Get favorites dances
+ $danceFavorites = $this->doctrine->getRepository(Dance::class)->findByUserId($this->security->getUser()->getId());
+
+ //Set dance default
+ $danceDefault = !empty($danceFavorites)?current($danceFavorites):null;
+