php namespace App Controllers use App Models MyModel use Core Controll

 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
<?php
namespace App\Controllers;
use App\Models\MyModel;
use Core\Controller;
use Core\User;
use Core\View;
class My extends Controller
{
public static function indexAction()
{
if (User::is_logged() == true) {
$args = [
'page_title' => 'Личный кабиет',
];
View::render('My/index', $args);
} else {
View::errorCode(404);
}
}
public static function settingsAction()
{
if (User::is_logged() == true) {
switch (trim(htmlspecialchars($_GET['sel']))) {
case 'password':
$args = [
'page_title' => 'Пароль'
];
View::render('My/password', $args);
break;
default:
$args = [
'page_title' => 'Настройки'
];
View::render('My/settings', $args);
break;
}
} else {
View::errorCode(404);
}
}
public static function logoutAction()
{
if (User::is_logged() == true) {
MyModel::logout_execute();
$args = [
'page_title' => 'Выход'
];
View::render('My/logout', $args);
} else {
View::errorCode(404);
}
}
}