<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
class HomeController extends AbstractController
{
/**
* @Route("/changeLocale", name="change_locale")
*/
public function changeLocale(Request $request)
{
$language = ['en', 'am', 'or'];
$lang = $request->request->get('lang');
$response['success'] = false;
if (in_array($lang, $language)) {
$response['success'] = true;
$this->get('session')->set('_locale', $lang);
}
return new JsonResponse(['success' => true]);
}
/**
* @Route("/", name="index")
*/
public function index()
{
// return $this->redirectToRoute('app_login');
$name=strtolower($this->getParameter('university_short_name'));
return $this->render('home/'.$name.'_index.html.twig', [
]);
}
/**
* @Route("/home", name="home")
*/
public function home()
{
$name=strtolower($this->getParameter('university_short_name'));
return $this->render('home/'.$name.'_home.html.twig');
}
}