src/Controller/HomeController.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. class HomeController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/changeLocale", name="change_locale")
  12.      */
  13.     public function changeLocale(Request $request)
  14.     {
  15.         $language = ['en''am''or'];
  16.         $lang $request->request->get('lang');
  17.         $response['success'] = false;
  18.         if (in_array($lang$language)) {
  19.             $response['success'] = true;
  20.             $this->get('session')->set('_locale'$lang);
  21.         }
  22.         return new JsonResponse(['success' => true]);
  23.     }
  24.     /**
  25.      * @Route("/", name="index")
  26.      */
  27.     public function index()
  28.     {
  29.         // return  $this->redirectToRoute('app_login');
  30.         $name=strtolower($this->getParameter('university_short_name'));
  31.         return $this->render('home/'.$name.'_index.html.twig', [
  32.           
  33.         ]);
  34.     }
  35.     /**
  36.      * @Route("/home", name="home")
  37.      */
  38.     public function home()
  39.     {
  40.         $name=strtolower($this->getParameter('university_short_name'));
  41.         return $this->render('home/'.$name.'_home.html.twig');
  42.     }
  43.     
  44. }