Completed
Push — master ( 188ffb...31684b )
by Maxime
02:48
created

BaseController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 58
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setupLayout() 0 8 1
A setupStateProvider() 0 6 1
A initStaticPart() 0 18 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
    public function __construct(LayoutManagerContract $layoutManager)
17
    {
18
        $this->layoutManager = $layoutManager;
19
        $this->setupLayout();
20
    }
21
22
    // ------------------------------------------------------------------------------------------------
23
    // ------------------------------------------------------------------------------------------------
24
    // ------------------------------------------------------------------------------------------------
25
26
27
    protected function setupLayout()
28
    {
29
        $this->layoutManager->setupLayout($this->layout);
30
        $this->setupStateProvider();
31
        $this->initStaticPart();
32
33
34
    }
35
36
    // ------------------------------------------------------------------------------------------------
37
38
    protected function setupStateProvider()
39
    {
40
        $interfaces = class_implements($this);
41
        $this->layoutManager->initInterfaces($interfaces, get_class($this));
42
43
    }
44
45
    // ------------------------------------------------------------------------------------------------
46
47
    protected function initStaticPart()
48
    {
49
        $this->layoutManager->initStaticPart(function($layoutManager)
50
        {
51
52
            $menu_top  = $layoutManager->getView()->make('expendable::admin.menu.top',[
53
                'languages'=>Language::all()
54
            ]);
55
            $menu_left = $layoutManager->getView()->make('expendable::admin.menu.left');
56
57
58
            $layoutManager->add([
59
                'state.menu' => $layoutManager->getState()->getRenderStateMenu(),
60
                'menu_top'   => $menu_top,
61
                'menu_left'  => $menu_left
62
            ]);
63
        });
64
    }
65
}