aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2018-02-03 20:21:13 +0100
committerThomas Lange <code@nerdmind.de>2018-02-03 20:21:13 +0100
commit9b9ff136acf374434f10f1b0b8d18fdc6d17de43 (patch)
tree4402c3e57b9416e3496ad4194d09cd3ca48c3d3b
parentca52e765e9dbd9407346b574cada9a93720e535d (diff)
downloadbigpipe-9b9ff136acf374434f10f1b0b8d18fdc6d17de43.tar.gz
bigpipe-9b9ff136acf374434f10f1b0b8d18fdc6d17de43.tar.xz
bigpipe-9b9ff136acf374434f10f1b0b8d18fdc6d17de43.zip
Move autoloader for classes into pagelets.php
This commit moves the "spl_autoload_register" function directly into the pagelets.php to reduce duplicate code within index.php and async.php.
-rw-r--r--async.php11
-rw-r--r--include/pagelets.php8
-rw-r--r--index.php11
3 files changed, 8 insertions, 22 deletions
diff --git a/async.php b/async.php
index 8d46c89..270a15a 100644
--- a/async.php
+++ b/async.php
@@ -10,17 +10,6 @@ function isAsyncRequest() {
# <<<
-#===============================================================================
-# Include classes and functions
-#===============================================================================
-spl_autoload_register(function($classname) {
- $classpath = 'include/classes/%s.php';
- $classname = str_replace('\\', '/', $classname);
-
- require_once sprintf($classpath, $classname);
-});
-
-// Outsourced to avoid duplicate code in index.php and async.php
require_once 'include/pagelets.php';
?>
<!DOCTYPE html>
diff --git a/include/pagelets.php b/include/pagelets.php
index 62c3ed9..f6734e2 100644
--- a/include/pagelets.php
+++ b/include/pagelets.php
@@ -5,6 +5,14 @@
$DEBUGGING = TRUE;
#===============================================================================
+# Autoload register for classes
+#===============================================================================
+spl_autoload_register(function($classname) {
+ $classname = str_replace('\\', '/', $classname);
+ require "classes/{$classname}.php";
+});
+
+#===============================================================================
# Check if BigPipe should be disabled
#===============================================================================
if(isset($_GET['bigpipe']) AND $_GET['bigpipe'] === '0') {
diff --git a/index.php b/index.php
index a47b752..59e8709 100644
--- a/index.php
+++ b/index.php
@@ -1,15 +1,4 @@
<?php
-#===============================================================================
-# Include classes and functions
-#===============================================================================
-spl_autoload_register(function($classname) {
- $classpath = 'include/classes/%s.php';
- $classname = str_replace('\\', '/', $classname);
-
- require_once sprintf($classpath, $classname);
-});
-
-// Outsourced to avoid duplicate code in index.php and async.php
require_once 'include/pagelets.php';
?>
<!DOCTYPE html>