]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Controller/DefaultController.php
Fetch config in constructor
[airbundle] / Controller / DefaultController.php
index f15ae32bccfcd4e6f9a5dc509a807303fc939424..f7df53b9387d215fd1b12315b5def2f87b68ca72 100644 (file)
@@ -2,9 +2,8 @@
 
 namespace Rapsys\AirBundle\Controller;
 
 
 namespace Rapsys\AirBundle\Controller;
 
-#use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 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;
 use Symfony\Bundle\FrameworkBundle\Translation\Translator;
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\HttpFoundation\Request;
@@ -14,15 +13,15 @@ use Symfony\Component\Form\FormError;
 
 #class DefaultController extends Controller {
 class DefaultController extends AbstractController {
 
 #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) {
 
        //Translator instance
        protected $translator;
 
        public function __construct(ContainerInterface $container, Translator $translator) {
-               //Set the container
-               $this->container = $container;
+               //Retrieve config
+               $this->config = $container->getParameter('rapsys_air');
 
                //Set the translator
                $this->translator = $translator;
 
                //Set the translator
                $this->translator = $translator;
@@ -33,7 +32,7 @@ class DefaultController extends AbstractController {
                $section = $this->translator->trans('Contact');
 
                //Set title
                $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
 
                //Create the form according to the FormType created previously.
                //And give the proper parameters
@@ -52,16 +51,16 @@ class DefaultController extends AbstractController {
                                $data = $form->getData();
 
                                //Get contact name
                                $data = $form->getData();
 
                                //Get contact name
-                               $contactName = $this->container->getParameter('rapsys_air.contact_name');
+                               $contactName = $this->config['contact_name'];
 
                                //Get contact mail
 
                                //Get contact mail
-                               $contactMail = $this->container->getParameter('rapsys_air.contact_mail');
+                               $contactMail = $this->config['contact_mail'];
 
                                //Get logo
 
                                //Get logo
-                               $logo = $this->container->getParameter('rapsys_air.logo');
+                               $logo = $this->config['logo'];
 
                                //Get title
 
                                //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;
 
                                //Get subtitle
                                $subtitle = $this->translator->trans('Hi,').' '.$contactName;
@@ -111,7 +110,7 @@ class DefaultController extends AbstractController {
                $section = $this->translator->trans('Index');
 
                //Set title
                $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]);
 
                //Render template
                return $this->render('@RapsysAir/page/index.html.twig', ['title' => $title, 'section' => $section]);
@@ -126,7 +125,7 @@ class DefaultController extends AbstractController {
                $section = $this->translator->trans('Admin');
 
                //Set title
                $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
 
                //Create the form according to the FormType created previously.
                //And give the proper parameters
@@ -300,7 +299,7 @@ class DefaultController extends AbstractController {
                $section = $this->translator->trans('Session %id%', ['%id%' => $id]);
 
                //Set title
                $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
 
                //Create the form according to the FormType created previously.
                //And give the proper parameters