LocaleController::switchLocaleAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the CMS Kernel package.
5
 *
6
 * Copyright (c) 2016-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LIN3S\CMSKernel\Infrastructure\Lin3sAdminBundle\Controller;
13
14
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15
use Symfony\Component\HttpFoundation\Request;
16
17
/**
18
 * @author Beñat Espiña <[email protected]>
19
 */
20
class LocaleController extends Controller
21
{
22
    public function switchLocaleAction(Request $request)
23
    {
24
        $locale = $locale = $request->getLocale();
25
        $request->getSession()->set('_locale', $locale);
26
27
        $refererUrl = $request->headers->get('referer');
28
        if (empty($refererUrl)) {
29
            return $this->redirectToRoute('lin3s_admin_dashboard');
30
        }
31
32
        return $this->redirect($refererUrl);
33
    }
34
}
35