3 namespace Rapsys\BlogBundle\Controller
; 
   5 use Symfony\Bundle\FrameworkBundle\Controller\Controller
; 
   7 class DefaultController 
extends Controller 
{ 
   8         //Redirect on first supported language version 
   9         public function rootAction() { 
  13                 //Supported application languages 
  14                 //XXX: Array for route validation is not supported by default (rapsys patch) 
  15                 $supportedLanguage = $this->getParameter('blog.locales'); 
  18                 if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { 
  20                         $httpAcceptLanguage = []; 
  23                         foreach(explode(',',str_replace('-','_',$_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $candidate) { 
  24                                 //Extract candidate and optional weight 
  25                                 @list($candidate, $weight) = explode(';', $candidate); 
  26                                 if (!empty($candidate)) { 
  27                                         $httpAcceptLanguage[!empty($weight)?$weight:1][] = $candidate; 
  32                         if (!empty($httpAcceptLanguage)) { 
  33                                 foreach($httpAcceptLanguage as $weight => $candidates) { 
  34                                         if (($candidate = array_intersect($candidates, $supportedLanguage)) && ($candidate = reset($candidate))) { 
  42                 //Redirect to localised homepage 
  43                 return $this->redirectToRoute('homepage', array('_locale' => $locale), 302);