]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Controller/CalendarController.php
Rename pack and user bundle aliases
[airbundle] / Controller / CalendarController.php
index 40da028a2c8cb96b4ed9bac5d5f5fa2c335aa8a9..3e6f65d973a59da799d33d9e6f51baa40b4fa73a 100644 (file)
@@ -25,20 +25,20 @@ class CalendarController extends DefaultController {
         * @return Response The rendered view
         */
        public function index(Request $request): Response {
         * @return Response The rendered view
         */
        public function index(Request $request): Response {
-               //Prevent non-admin to access here
-               $this->denyAccessUnlessGranted('ROLE_ADMIN', null, $this->translator->trans('Unable to access this page without role %role%!', ['%role%' => $this->translator->trans('Admin')]));
-
-               //Fetch doctrine
-               #$doctrine = $this->getDoctrine();
-
-               //Set section
-               $section = $this->translator->trans('Calendar oauth form');
+               //Without admin role
+               if (!$this->checker->isGranted('ROLE_ADMIN')) {
+                       //Throw 403
+                       throw $this->createAccessDeniedException($this->translator->trans('Unable to access this page without role %role%!', ['%role%' => $this->translator->trans('Admin')]));
+               }
 
                //Set description
                $this->context['description'] = $this->translator->trans('Initiate calendar oauth process');
 
                //Set title
 
                //Set description
                $this->context['description'] = $this->translator->trans('Initiate calendar oauth process');
 
                //Set title
-               $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
+               $this->context['title']['page'] = $this->translator->trans('Oauth form');
+
+               //Set section
+               $this->context['title']['section'] = $this->translator->trans('Calendar');
 
                //Create the form according to the FormType created previously.
                //And give the proper parameters
 
                //Create the form according to the FormType created previously.
                //And give the proper parameters
@@ -129,13 +129,16 @@ class CalendarController extends DefaultController {
                }
 
                //Render template
                }
 
                //Render template
-               return $this->render('@RapsysAir/calendar/index.html.twig', ['title' => $title, 'section' => $section, 'form' => $form->createView()]+$this->context);
+               return $this->render('@RapsysAir/calendar/index.html.twig', ['form' => $form->createView()]+$this->context);
        }
 
        /**
         * List all sessions for the organizer
         *
        }
 
        /**
         * List all sessions for the organizer
         *
-        * @desc Display all sessions for the user with an application or login form
+        * Display all sessions for the user with an application or login form
+        *
+        * @todo Fetch all google calendar and let user select one
+        * @todo Then save the calendar fucking id in database ??? with token infos !!!
         *
         * @param Request $request The request instance
         *
         *
         * @param Request $request The request instance
         *
@@ -149,7 +152,10 @@ class CalendarController extends DefaultController {
                $this->context['description'] = $this->translator->trans('Finish calendar oauth process');
 
                //Set title
                $this->context['description'] = $this->translator->trans('Finish calendar oauth process');
 
                //Set title
-               $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
+               $this->context['title']['page'] = $this->translator->trans('Oauth callback');
+
+               //Set section
+               $this->context['title']['section'] = $this->translator->trans('Calendar');
 
                //With code
                if (!empty($code = $request->get('code'))) {
 
                //With code
                if (!empty($code = $request->get('code'))) {
@@ -199,7 +205,7 @@ class CalendarController extends DefaultController {
                                //With valid token
                                } else {
                                        //Retrieve cache object
                                //With valid token
                                } else {
                                        //Retrieve cache object
-                                       $cache = new FilesystemAdapter($this->config['cache']['namespace'], $this->config['cache']['lifetime'], $this->config['cache']['directory']);
+                                       $cache = new FilesystemAdapter($this->config['cache']['namespace'], $this->config['cache']['lifetime'], $this->config['path']['cache']);
 
                                        //Retrieve calendars
                                        $cacheCalendars = $cache->getItem('calendars');
 
                                        //Retrieve calendars
                                        $cacheCalendars = $cache->getItem('calendars');
@@ -254,6 +260,6 @@ class CalendarController extends DefaultController {
                }
 
                //Render template
                }
 
                //Render template
-               return $this->render('@RapsysAir/calendar/callback.html.twig', ['title' => $title, 'section' => $section]+$this->context);
+               return $this->render('@RapsysAir/calendar/callback.html.twig', $this->context);
        }
 }
        }
 }