Skip to content

Commit

Permalink
[-] Fix bug with locale redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
madef committed May 16, 2015
1 parent 6a882c8 commit 08e9754
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Madef/CmsBundle/Controller/LanguageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ class LanguageController extends Controller
public function adminRouteAction(Request $request)
{
$language = $request->getPreferredLanguage();

if (empty($language)) {
$language = 'en';
}

if (strlen($language) > 2) {
$languages = explode('_', $language);
$language = $languages[0];
}

return $this->redirect($this->generateUrl('madef_cms_admin_home', array('_locale' => $language)));
}

Expand All @@ -56,10 +62,16 @@ public function adminRouteAction(Request $request)
public function frontRouteAction(Request $request)
{
$language = $request->getPreferredLanguage();

if (empty($language)) {
$language = 'en';
}

if (strlen($language) > 2) {
$languages = explode('_', $language);
$language = $languages[0];
}

return $this->redirect($this->generateUrl('madef_cms_front_display_page', array('_locale' => $language)));
}
}

0 comments on commit 08e9754

Please sign in to comment.