-
-
Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathIndex.php
More file actions
83 lines (68 loc) · 1.96 KB
/
Index.php
File metadata and controls
83 lines (68 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php namespace Backend\Controllers;
use Backend;
use Redirect;
use BackendMenu;
use Backend\Classes\Controller;
use Backend\Widgets\ReportContainer;
use Winter\Storm\Support\Arr;
/**
* Dashboard controller
*
* @package winter\wn-backend-module
* @author Alexey Bobkov, Samuel Georges
*
*/
class Index extends Controller
{
use \Backend\Traits\InspectableContainer;
/**
* @var array Permissions required to view this page.
* @see checkPermissionRedirect()
*/
public $requiredPermissions = [];
/**
* Constructor.
*/
public function __construct()
{
parent::__construct();
BackendMenu::setContextOwner('Winter.Backend');
$this->addCss('/modules/backend/assets/css/dashboard/dashboard.css', 'core');
}
public function index()
{
if ($redirect = $this->checkPermissionRedirect()) {
return $redirect;
}
$this->initReportContainer();
$this->pageTitle = 'backend::lang.dashboard.menu_label';
BackendMenu::setContextMainMenu('dashboard');
}
public function index_onInitReportContainer()
{
$this->initReportContainer();
return ['#dashReportContainer' => $this->widget->reportContainer->render()];
}
/**
* Prepare the report widget used by the dashboard
* @param Model $model
* @return void
*/
protected function initReportContainer()
{
new ReportContainer($this, 'config_dashboard.yaml');
}
/**
* Custom permissions check that will redirect to the next
* available menu item, if permission to this page is denied.
*/
protected function checkPermissionRedirect()
{
if (!$this->user->hasAccess('backend.access_dashboard')) {
if ($first = Arr::first(BackendMenu::listMainMenuItems())) {
return Redirect::intended($first->url);
}
return Backend::redirect('backend/users/myaccount');
}
}
}