-
Notifications
You must be signed in to change notification settings - Fork 22
/
App.php
63 lines (48 loc) · 1.85 KB
/
App.php
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
<?php
declare(strict_types=1);
namespace Atk4\Login\Demos;
use Atk4\Login\Acl;
use Atk4\Login\Auth;
use Atk4\Ui\Layout;
/**
* Example implementation of your Authenticated application.
*/
class App extends \Atk4\Ui\App
{
public $auth;
public $title = 'Demo App';
protected function init(): void
{
parent::init();
$this->initLayout([Layout\Admin::class]);
// Construct menu
$this->layout->menuLeft->addItem(['Dashboard', 'icon' => 'info'], ['index']);
$this->layout->menuLeft->addItem(['Setup demo database', 'icon' => 'cogs'], ['admin-setup']);
$g = $this->layout->menuLeft->addGroup(['Forms']);
$g->addItem(['Sign-up form', 'icon' => 'edit'], ['form-register']);
$g->addItem(['Login form', 'icon' => 'edit'], ['form-login']);
$g->addItem(['Forgot password form', 'icon' => 'edit'], ['form-forgot']);
$g = $this->layout->menuLeft->addGroup(['Admin']);
$g->addItem(['User Admin', 'icon' => 'users'], ['admin-users']);
$g->addItem(['Role Admin', 'icon' => 'tasks'], ['admin-roles']);
$g = $this->layout->menuLeft->addGroup(['App demo with ACL']);
$g->addItem(['Client list (for ACL testing)', 'icon' => 'table'], ['acl-clients']);
$this->initAuth(false);
if ($this->auth->isLoggedIn()) {
$this->auth->addUserMenu();
}
}
public function initAuth($check = true)
{
$this->auth = new Auth(['check' => $check, 'pageDashboard' => 'index']);
$this->auth->setApp($this);
// Can not setmodel at this stage :(
$m = new \Atk4\Login\Model\User($this->db);
$this->auth->setModel($m);
}
public function initAcl()
{
// adding this requires user to be logged in, so we can't run this in wrapping app :(
$this->auth->setAcl(new Acl(), $this->db);
}
}