|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Controller\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use Core\Application; |
|
6
|
|
|
use Core\Utils\ArrayUtils; |
|
7
|
|
|
use Core\ViewModel; |
|
8
|
|
|
use Prob\ArrayUtil\KeyGlue; |
|
9
|
|
|
|
|
10
|
|
|
class Welcome { |
|
11
|
|
|
public function __construct(ViewModel $view, $urlPattern) |
|
12
|
|
|
{ |
|
13
|
|
|
$view->set('nav', $urlPattern); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
public function index(ViewModel $view) { |
|
17
|
|
|
$view->set('siteUrl', Application::getUrl()); |
|
18
|
|
|
$view->set('sitePublicUrl', Application::getPublicUrl()); |
|
19
|
|
|
|
|
20
|
|
|
$view->set('absolutePath', realpath(__DIR__ . '/../../')); |
|
21
|
|
|
$view->set('phpVersion', PHP_VERSION); |
|
22
|
|
|
$view->set('os', PHP_OS); |
|
23
|
|
|
$view->set('sapi', PHP_SAPI); |
|
24
|
|
|
|
|
25
|
|
|
return 'server'; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function viewRoutePaths(ViewModel $view) { |
|
29
|
|
|
$routePaths = AdminService::getRoutePaths(); |
|
30
|
|
|
unset($routePaths['namespace']); |
|
31
|
|
|
|
|
32
|
|
|
$view->set('namespace', AdminService::getRoutePaths()['namespace']); |
|
33
|
|
|
$view->set('routePaths', $routePaths); |
|
34
|
|
|
|
|
35
|
|
|
return 'route'; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function viewEvents(ViewModel $view) { |
|
39
|
|
|
$glue = new KeyGlue(); |
|
40
|
|
|
$glue->setGlueCharacter(' / '); |
|
41
|
|
|
$glue->setArray(AdminService::getEventHandlers()); |
|
42
|
|
|
|
|
43
|
|
|
$events = $glue->glueKeyAndContainValue(); |
|
44
|
|
|
|
|
45
|
|
|
foreach($events as $k => $v) { |
|
46
|
|
|
if(is_string($events[$k]) == false) { |
|
|
|
|
|
|
47
|
|
|
$events[$k] = '{ Closure function }'; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$view->set('events', $events); |
|
52
|
|
|
|
|
53
|
|
|
return 'event'; |
|
54
|
|
|
} |
|
55
|
|
|
} |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.