ThemeController::switchAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Neirda\Bundle\LiipThemeProvider\Controller;
4
5
use Neirda\Bundle\LiipThemeProvider\Theme\ThemeContainerInterface;
6
use Liip\ThemeBundle\ActiveTheme;
7
use Liip\ThemeBundle\Controller\ThemeController as Base;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class ThemeController extends Base
11
{
12
    /**
13
     * @var null|ThemeContainerInterface
14
     */
15
    protected $themeContainer = null;
16
17
    /**
18
     * {@inheritdoc}
19
     * @param null|ThemeContainerInterface $themeContainer
20
     */
21
    public function __construct(ActiveTheme $activeTheme, array $themes, array $cookieOptions, ThemeContainerInterface $themeContainer = null)
22
    {
23
        $this->themeContainer = $themeContainer;
24
        parent::__construct($activeTheme, $themes, $cookieOptions);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function switchAction(Request $request)
31
    {
32
        if ($this->themeContainer instanceof ThemeContainerInterface) {
33
            $this->themes = $this->themeContainer->getThemeList();
34
        }
35
36
        return parent::switchAction($request);
37
    }
38
}
39