]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Controller/DefaultController.php
Rename user controller to organizer
[airbundle] / Controller / DefaultController.php
index 8b27ce6f0dda868c7a4b1e4accb3d8e613e118ab..7f3037ca4a8586ee92305f25725e5e9fbcef46a6 100644 (file)
@@ -19,24 +19,33 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\Routing\RouterInterface;
 use Symfony\Component\Translation\TranslatorInterface;
 use Rapsys\UserBundle\Utils\Slugger;
+use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait;
+use Symfony\Component\DependencyInjection\ContainerAwareTrait;
 
 
-class DefaultController extends AbstractController {
-       //Config array
+class DefaultController {
+       use ControllerTrait;
+
+       ///Config array
        protected $config;
 
-       //Context array
+       ///Context array
        protected $context;
 
-       //Router instance
+       ///Router instance
        protected $router;
 
-       //Slugger instance
+       ///Slugger instance
        protected $slugger;
 
-       //Translator instance
+       ///Translator instance
        protected $translator;
 
+       /**
+        * @var ContainerInterface
+        */
+       protected $container;
+
        /**
         * Inject container and translator interface
         *
@@ -49,6 +58,9 @@ class DefaultController extends AbstractController {
                //Retrieve config
                $this->config = $container->getParameter($this->getAlias());
 
+               //Set the container
+               $this->container = $container;
+
                //Set the router
                $this->router = $router;
 
@@ -167,7 +179,7 @@ class DefaultController extends AbstractController {
                $section = $this->translator->trans('Index');
 
                //Set title
-               $title = $section.' - '.$this->context['site_title'];
+               $title = $section.' - '.$this->translator->trans($this->config['site']['title']);
 
                //Init context
                $context = [];
@@ -216,10 +228,11 @@ class DefaultController extends AbstractController {
                );
 
                //Fetch calendar
-               $calendar = $doctrine->getRepository(Session::class)->fetchCalendarByDatePeriod($this->translator, $period, null, $request->get('session'), true);
+               $calendar = $doctrine->getRepository(Session::class)->fetchCalendarByDatePeriod($this->translator, $period, null, $request->get('session'), !$this->isGranted('IS_AUTHENTICATED_REMEMBERED'));
 
                //Fetch locations
-               $locations = $doctrine->getRepository(Location::class)->fetchTranslatedLocationByDatePeriod($this->translator, $period, true);
+               //XXX: we want to display all active locations anyway
+               $locations = $doctrine->getRepository(Location::class)->fetchTranslatedLocationByDatePeriod($this->translator, $period/*, !$this->isGranted('IS_AUTHENTICATED_REMEMBERED')*/);
 
                //Render the view
                return $this->render('@RapsysAir/default/index.html.twig', ['title' => $title, 'section' => $section, 'calendar' => $calendar, 'locations' => $locations]+$context+$this->context);
@@ -238,7 +251,7 @@ class DefaultController extends AbstractController {
                $section = $this->translator->trans('Regulation');
 
                //Set title
-               $title = $section.' - '.$this->context['site_title'];
+               $title = $section.' - '.$this->translator->trans($this->config['site']['title']);
 
                //Render template
                return $this->render('@RapsysAir/default/regulation.html.twig', ['title' => $title, 'section' => $section]+$this->context);