AdminController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 13
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 3 1
A localeAction() 0 8 2
A __construct() 0 5 1
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace FSi\Bundle\AdminBundle\Controller;
13
14
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
15
use Symfony\Component\HttpFoundation\RedirectResponse;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\Routing\RouterInterface;
19
20
class AdminController
21
{
22
    /**
23
     * @var EngineInterface
24
     */
25
    private $templating;
26
27
    /**
28
     * @var RouterInterface
29
     */
30
    private $router;
31
32
    /**
33
     * @var string
34
     */
35
    private $indexActionTemplate;
36
37
    public function __construct(EngineInterface $templating, RouterInterface $router, string $indexActionTemplate)
38
    {
39
        $this->templating = $templating;
40
        $this->router = $router;
41
        $this->indexActionTemplate = $indexActionTemplate;
42
    }
43
44
    public function indexAction(): Response
45
    {
46
        return $this->templating->renderResponse($this->indexActionTemplate);
47
    }
48
49
    public function localeAction(string $_locale, Request $request): RedirectResponse
50
    {
51
        $request->getSession()->set('admin_locale', $_locale);
52
53
        return new RedirectResponse(
54
            $request->query->has('redirect_uri')
55
                ? $request->query->get('redirect_uri')
56
                : $this->router->generate('fsi_admin')
57
        );
58
    }
59
}
60