-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.template.php
42 lines (34 loc) · 1.21 KB
/
router.template.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
<?php
/**
* _ __
* ___ ____ ___ ___ _________ _(_) /____
* / _ \/ __ `__ \/ _ \/ ___/ __ `/ / / ___/
* / __/ / / / / / __/ / / /_/ / / (__ )
* \___/_/ /_/ /_/\___/_/ \__,_/_/_/____/
*
* (c) Claudio Procida 2008-2024
*
* @format
*/
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/vendor/emeraldion/emerails/include/common.inc.php';
require_once __DIR__ . '/helpers/application_helper.php';
use Emeraldion\EmeRails\Helpers\HTTP;
if (isset($_REQUEST['controller']) && !empty($_REQUEST['controller'])) {
// Include controller class
$controller_file = __DIR__ . "/controllers/{$_REQUEST['controller']}_controller.php";
if (!file_exists($controller_file)) {
HTTP::error(404);
}
require $controller_file;
$main_controller_class = joined_lower_to_camel_case($_REQUEST['controller']) . 'Controller';
// Instantiate main controller
$main_controller = new $main_controller_class();
// Set main controller's base path
$main_controller->set_base_path(__DIR__);
// Request rendering of the page
// (If action didn't already do it before)
$main_controller->render_page();
} else {
HTTP::error(500);
}