-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.php
More file actions
executable file
·43 lines (29 loc) · 1.03 KB
/
application.php
File metadata and controls
executable file
·43 lines (29 loc) · 1.03 KB
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
<?php
use vxWeb\User\vxWebRoleHierarchy;
use vxWeb\User\SessionUserProvider;
use vxPHP\Application\Application;
use vxPHP\Http\Response;
use vxPHP\Routing\Router;
use vxPHP\Http\Request;
// return empty response for OPTION request
if (Request::createFromGlobals()->getMethod() === 'OPTIONS') {
(new Response())->send();
exit();
}
// $loader is initialized in bootstrap.php
// place additional libraries here
$app = Application::getInstance();
// set role hierarchy
$app->setRoleHierarchy(new vxWebRoleHierarchy());
// set current user; might be required for route and menu authentication
if($currentUser = (new SessionUserProvider())->getSessionUser()) {
$app->setCurrentUser($currentUser);
}
// ensure the presence of a valid assets path
if(!is_dir($app->getAbsoluteAssetsPath())) {
throw new \Exception(sprintf("Assets path '%s' not found.", $app->getRelativeAssetsPath()));
}
// set up routing
$scriptName = basename($_SERVER['SCRIPT_NAME']);
$router = new Router($app->getConfig()->routes[$scriptName]);
$app->setRouter($router);