-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
39 lines (33 loc) · 1.02 KB
/
index.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
<?php
// Load Global Defines
require_once dirname(__FILE__) . '/../config/defines.php';
require_once JEFF_BASE_DIR . 'config/routes.php';
// Init Parameter Manager
require_once JEFF_BASE_DIR . 'app/model/ParamManager.php';
$param_manager = new ParamManager();
// Load Controller Parent Class
require_once JEFF_BASE_DIR . 'app/controller/Controller.php';
// Check URL path
$url_path = $param_manager->getParam('url_path', '');
// Determine which action to instantiate
$action = getMatchingController($url_path);
if(is_null($action)) {
// No matching action - HTTP 404
require_once JEFF_BASE_DIR . 'app/controller/error/NotFound.php';
$action = new Error_NotFound();
}
// Check input params based on action
$action->init($param_manager);
$error_messages = $action->loadParams();
if(!empty($error_messages)) {
// Param error - HTTP 400
$action->httpBadRequest();
}
// Execute action
try {
$action->perform();
}
catch (Exception $ex) {
// Unanticipated exception - HTTP 500
$action->httpInternalServerError();
}