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
|
|
|
} |