From 96d3f1eabadf865748f527ee1c86a2f816574bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Fri, 8 Aug 2014 14:38:45 +0200 Subject: [PATCH] moved parts of libs loading into AutoLoader --- application/core/AutoLoader.php | 21 ++++++++++++++------- application/core/ManiaControl.php | 2 -- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/application/core/AutoLoader.php b/application/core/AutoLoader.php index 7260c92d..305d94ba 100644 --- a/application/core/AutoLoader.php +++ b/application/core/AutoLoader.php @@ -27,17 +27,24 @@ abstract class AutoLoader { $classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className); // Core file - $classDirectoryPath = preg_replace('/ManiaControl/', 'core', $classPath, 1); - $filePath = ManiaControlDir . $classDirectoryPath . '.php'; - if (file_exists($filePath)) { - require_once $filePath; + $coreClassPath = preg_replace('/ManiaControl/', 'core', $classPath, 1); + $coreFilePath = ManiaControlDir . $coreClassPath . '.php'; + if (file_exists($coreFilePath)) { + include_once $coreFilePath; return; } // Plugin file - $filePath = ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR . $classPath . '.php'; - if (file_exists($filePath)) { - include_once $filePath; + $pluginFilePath = ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR . $classPath . '.php'; + if (file_exists($pluginFilePath)) { + include_once $pluginFilePath; + return; + } + + // Lib file + $libFilePath = ManiaControlDir . 'libs' . DIRECTORY_SEPARATOR . $classPath . '.php'; + if (file_exists($libFilePath)) { + include_once $libFilePath; return; } } diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index c6897164..d45dd85b 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -31,8 +31,6 @@ use Maniaplanet\DedicatedServer\Connection; use Maniaplanet\DedicatedServer\Xmlrpc\AuthenticationException; use Maniaplanet\DedicatedServer\Xmlrpc\TransportException; -require_once ManiaControlDir . '/libs/Maniaplanet/DedicatedServer/Connection.php'; -require_once ManiaControlDir . '/libs/FML/autoload.php'; require_once ManiaControlDir . '/libs/Symfony/autoload.php'; require_once ManiaControlDir . '/libs/curl-easy/autoload.php';