BaseController::setupLayout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php namespace Distilleries\Expendable\Http\Controllers\Backend\Base;
2
3
use Distilleries\Expendable\Contracts\LayoutManagerContract;
4
use Distilleries\Expendable\Http\Controllers\Controller;
5
use Distilleries\Expendable\Models\Language;
6
7
8
class BaseController extends Controller {
9
10
11
    protected $layoutManager;
12
    protected $layout = 'expendable::admin.layout.default';
13
14
    // ------------------------------------------------------------------------------------------------
15
16 150
    public function __construct(LayoutManagerContract $layoutManager)
17
    {
18 150
        $this->layoutManager = $layoutManager;
19 150
        $this->setupLayout();
20
    }
21
22
    // ------------------------------------------------------------------------------------------------
23
    // ------------------------------------------------------------------------------------------------
24
    // ------------------------------------------------------------------------------------------------
25
26
27 150
    protected function setupLayout()
28
    {
29 150
        $this->layoutManager->setupLayout($this->layout);
30 150
        $this->setupStateProvider();
31 150
        $this->initStaticPart();
32
33
34
    }
35
36
    // ------------------------------------------------------------------------------------------------
37
38 150
    protected function setupStateProvider()
39
    {
40 150
        $interfaces = class_implements($this);
41 150
        $this->layoutManager->initInterfaces($interfaces, get_class($this));
42
43
    }
44
45
    // ------------------------------------------------------------------------------------------------
46
47 120
    protected function initStaticPart()
48
    {
49
        $this->layoutManager->initStaticPart(function($layoutManager)
50
        {
51
52 120
            $menu_top  = $layoutManager->getView()->make('expendable::admin.menu.top', [
53 120
                'languages'=>Language::all()
54
            ]);
55 120
            $menu_left = $layoutManager->getView()->make('expendable::admin.menu.left');
56
57
58 120
            $layoutManager->add([
59 120
                'state.menu' => $layoutManager->getState()->getRenderStateMenu(),
60 120
                'menu_top'   => $menu_top,
61 120
                'menu_left'  => $menu_left
62
            ]);
63 120
        });
64
    }
65
}