]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Controller/CalendarController.php
Rename rapsysair:calendar2 command to rapsysair:calendar
[airbundle] / Controller / CalendarController.php
index 7b61e9e48b53cfd449f6b8ed0a889c337f1e14da..663349cac91b6e01c9cc9c5ab1b4d35d0c654d7b 100644 (file)
@@ -18,32 +18,32 @@ class CalendarController extends DefaultController {
        /**
         * Calendar authorization
         *
        /**
         * Calendar authorization
         *
-        * @desc Initiate calendar oauth process
+        * Initiate calendar oauth process
         *
         * @param Request $request The request instance
         *
         * @return Response The rendered view
         */
        public function index(Request $request): Response {
         *
         * @param Request $request The request instance
         *
         * @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
                $form = $this->createForm('Rapsys\AirBundle\Form\CalendarType', ['calendar' => $this->config['calendar']['calendar'], 'prefix' => $this->config['calendar']['prefix']], [
 
                //Create the form according to the FormType created previously.
                //And give the proper parameters
                $form = $this->createForm('Rapsys\AirBundle\Form\CalendarType', ['calendar' => $this->config['calendar']['calendar'], 'prefix' => $this->config['calendar']['prefix']], [
-                       'action' => $this->generateUrl('rapsys_air_calendar'),
+                       'action' => $this->generateUrl('rapsysair_calendar'),
                        'method' => 'POST'
                ]);
 
                        'method' => 'POST'
                ]);
 
@@ -70,7 +70,7 @@ class CalendarController extends DefaultController {
                                                'application_name' => $data['project'],
                                                'client_id' => $data['client'],
                                                'client_secret' => $data['secret'],
                                                'application_name' => $data['project'],
                                                'client_id' => $data['client'],
                                                'client_secret' => $data['secret'],
-                                               'redirect_uri' => $redirect = $this->generateUrl('rapsys_air_calendar_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
+                                               'redirect_uri' => $redirect = $this->generateUrl('rapsysair_calendar_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
                                                'scopes' => [Calendar::CALENDAR, Calendar::CALENDAR_EVENTS],
                                                'access_type' => 'offline',
                                                'approval_prompt' => 'force'
                                                'scopes' => [Calendar::CALENDAR, Calendar::CALENDAR_EVENTS],
                                                'access_type' => 'offline',
                                                'approval_prompt' => 'force'
@@ -93,7 +93,7 @@ class CalendarController extends DefaultController {
 #                              $googleClient->addScope(Calendar::CALENDAR_EVENTS);
 #
 #                              //Set redirect uri
 #                              $googleClient->addScope(Calendar::CALENDAR_EVENTS);
 #
 #                              //Set redirect uri
-#                              $googleClient->setRedirectUri($redirect = $this->generateUrl('rapsys_air_calendar_callback', [], UrlGeneratorInterface::ABSOLUTE_URL));
+#                              $googleClient->setRedirectUri($redirect = $this->generateUrl('rapsysair_calendar_callback', [], UrlGeneratorInterface::ABSOLUTE_URL));
 #
 #                              //Set offline access
 #                              $googleClient->setAccessType('offline');
 #
 #                              //Set offline access
 #                              $googleClient->setAccessType('offline');
@@ -129,7 +129,7 @@ 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);
        }
 
        /**
        }
 
        /**
@@ -152,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'))) {
@@ -257,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);
        }
 }
        }
 }