-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootstrap.php
48 lines (38 loc) · 1.11 KB
/
Bootstrap.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
<?php
use App\Component\ControllerProvider;
use App\Component\View;
use App\Frontend\Model\ErrorController;
use App\Component\SymfonyContainer;
$container = (new SymfonyContainer())->getContainer();
$controller = new ControllerProvider();
$route = $_GET['cl'];
$action = $_GET ['page'] ?? '0';
$isAdmin = (!empty($_GET['admin']) && $_GET['admin'] === 'true');
if ($isAdmin) {
$controllerList = $controller->getBackEndList();
} else {
$controllerList = $controller->getFrontEndList();
}
$isFind = false;
foreach ($controllerList as $controller) {
if (strtolower($controller::ROUTE) === $route) {
$isFind = true;
$controller = $container->get($controller);
$actionName = $action.'Action';
if ($isAdmin) {
$controller->init();
}
if (method_exists($controller, $actionName)) {
$controller->{$actionName}();
} else {
$controller->action();
}
}
}
if (!$isFind) {
$class = $container->get(ErrorController::class);
$class->action();
}
/** @var View $view */
$view = $container->get(View::class);
return $view;