<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class LandingController extends AbstractController
{
/**
* @Route("/" , name="index_landing_new")
*/
public function landingAction(Request $request) {
$localeAvailable = array( 'en', 'fr', 'ar');
$localeUser = substr($request->getPreferredLanguage(), 0, 2);
$localeApp = $request->attributes->get('_locale');
//Redirect to the good locale page
//only if the locale user is on our manager locale and it is not the current locale of the application
if(in_array($localeUser, $localeAvailable) && $localeApp!=$localeUser){
return $this->redirect($this->generateUrl("app_front_main_index", array('_locale' => $localeUser)));
}
return array();
}
}