]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Controller/DefaultController.php
Cleanup
[airbundle] / Controller / DefaultController.php
index 5ec04eb6f404e9aeeb2761859eb112bae5711d6a..b0aed10306b0d08891cc24732f149f9ed7812fe3 100644 (file)
@@ -2,9 +2,8 @@
 
 namespace Rapsys\AirBundle\Controller;
 
-#use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
-use Psr\Container\ContainerInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Bundle\FrameworkBundle\Translation\Translator;
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\HttpFoundation\Request;
@@ -12,29 +11,27 @@ use Rapsys\AirBundle\Entity\Session;
 use Rapsys\AirBundle\Entity\Application;
 use Symfony\Component\Form\FormError;
 
-#class DefaultController extends Controller {
 class DefaultController extends AbstractController {
-       //Container instance
-       protected $container;
+       //Config array
+       protected $config;
 
        //Translator instance
        protected $translator;
 
        public function __construct(ContainerInterface $container, Translator $translator) {
-               //Set the container
-               $this->container = $container;
+               //Retrieve config
+               $this->config = $container->getParameter($this->getAlias());
 
                //Set the translator
                $this->translator = $translator;
        }
 
-       //FIXME: we need to change the $this->container->getParameter($alias.'.xyz') to $this->container->getParameter($alias)['xyz']
        public function contactAction(Request $request) {
                //Set section
                $section = $this->translator->trans('Contact');
 
                //Set title
-               $title = $section.' - '.$this->translator->trans($this->container->getParameter('rapsys_air.title'));
+               $title = $section.' - '.$this->translator->trans($this->config['title']);
 
                //Create the form according to the FormType created previously.
                //And give the proper parameters
@@ -53,16 +50,16 @@ class DefaultController extends AbstractController {
                                $data = $form->getData();
 
                                //Get contact name
-                               $contactName = $this->container->getParameter('rapsys_air.contact_name');
+                               $contactName = $this->config['contact_name'];
 
                                //Get contact mail
-                               $contactMail = $this->container->getParameter('rapsys_air.contact_mail');
+                               $contactMail = $this->config['contact_mail'];
 
                                //Get logo
-                               $logo = $this->container->getParameter('rapsys_air.logo');
+                               $logo = $this->config['logo'];
 
                                //Get title
-                               $title = $this->translator->trans($this->container->getParameter('rapsys_air.title'));
+                               $title = $this->translator->trans($this->config['title']);
 
                                //Get subtitle
                                $subtitle = $this->translator->trans('Hi,').' '.$contactName;
@@ -112,7 +109,7 @@ class DefaultController extends AbstractController {
                $section = $this->translator->trans('Index');
 
                //Set title
-               $title = $section.' - '.$this->translator->trans($this->container->getParameter('rapsys_air.title'));
+               $title = $section.' - '.$this->translator->trans($this->config['title']);
 
                //Render template
                return $this->render('@RapsysAir/page/index.html.twig', ['title' => $title, 'section' => $section]);
@@ -127,7 +124,7 @@ class DefaultController extends AbstractController {
                $section = $this->translator->trans('Admin');
 
                //Set title
-               $title = $section.' - '.$this->translator->trans($this->container->getParameter('rapsys_air.title'));
+               $title = $section.' - '.$this->translator->trans($this->config['title']);
 
                //Create the form according to the FormType created previously.
                //And give the proper parameters
@@ -301,7 +298,7 @@ class DefaultController extends AbstractController {
                $section = $this->translator->trans('Session %id%', ['%id%' => $id]);
 
                //Set title
-               $title = $section.' - '.$this->translator->trans($this->container->getParameter('rapsys_air.title'));
+               $title = $section.' - '.$this->translator->trans($this->config['title']);
 
                //Create the form according to the FormType created previously.
                //And give the proper parameters
@@ -320,4 +317,11 @@ class DefaultController extends AbstractController {
 
                return $this->render('@RapsysAir/admin/session.html.twig', ['title' => $title, 'section' => $section, /*'form' => $form->createView(),*/ 'session' => $session]);
        }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function getAlias() {
+               return 'rapsys_air';
+       }
 }