Refactor PHP init code.

This commit is contained in:
Lars Jung 2014-09-20 22:21:13 +02:00
parent f78e6dfc64
commit b94530b93d
2 changed files with 23 additions and 12 deletions

View file

@ -1,8 +1,28 @@
<?php
class Setup {
class Bootstrap {
public static function run() {
Bootstrap::setup();
$app = new App();
if (Util::has_request_param("action")) {
$api = new Api($app);
$api->apply();
} else {
define("FALLBACK", $app->get_fallback());
normalized_require_once("page");
}
}
public static function setup() {
if (defined("NAME")) {
return;
}
public static function init() {
// MISC
putenv("LANG=en_US.UTF-8");

View file

@ -21,13 +21,4 @@ function __autoload($class_name) {
normalized_require_once("class-" . strtolower($class_name));
}
Setup::init();
$app = new App();
if (Util::has_request_param("action")) {
$api = new Api($app);
$api->apply();
} else {
define("FALLBACK", $app->get_fallback());
normalized_require_once("page");
}
Bootstrap::run();