Make Bootstrap static again.

This commit is contained in:
Lars Jung 2015-05-13 17:33:43 +02:00
parent ae677a2194
commit 9611aed707
2 changed files with 5 additions and 10 deletions

View file

@ -2,16 +2,11 @@
class Bootstrap {
public static function main() {
(new Bootstrap())->run();
}
private static $autopaths = ['core', 'ext'];
public function run() {
public static function run() {
spl_autoload_register([$this, 'autoload']);
spl_autoload_register(['Bootstrap', 'autoload']);
putenv('LANG=en_US.UTF-8');
setlocale(LC_CTYPE, 'en_US.UTF-8');
date_default_timezone_set(@date_default_timezone_get());
@ -34,14 +29,14 @@ class Bootstrap {
}
}
public function autoload($class_name) {
public static function autoload($class_name) {
$filename = 'class-' . strtolower($class_name) . '.php';
foreach (Bootstrap::$autopaths as $path) {
$file = __DIR__ . '/' . $path . '/' . $filename;
if (file_exists($file)) {
require $file;
require_once $file;
return true;
}
}

View file

@ -9,4 +9,4 @@ if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '<')) {
}
require_once __DIR__ . '/../backend/php/class-bootstrap.php';
Bootstrap::main();
Bootstrap::run();