From c246e5d74b1fb88ada602764f247942f2eebc4ca Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 28 Dec 2020 19:47:39 +0100 Subject: Revert "Extract autoloading process (#3283)" This reverts commit 46cb89adf842e2fbac254fc99355d6577e4e86eb. --- lib/autoload.php | 74 -------------------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 lib/autoload.php (limited to 'lib/autoload.php') diff --git a/lib/autoload.php b/lib/autoload.php deleted file mode 100644 index 5be952876..000000000 --- a/lib/autoload.php +++ /dev/null @@ -1,74 +0,0 @@ -searchPath[] = $path; - } - if (is_array($path)) { - array_push($this->searchPath, ...$path); - } - } - - /** - * Load class file if found. - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - require $file; - } - } - - /** - * Find the file containing the class definition. - */ - public function findFile($class) { - // This match most of classes directly - foreach ($this->searchPath as $path) { - $file = $path . DIRECTORY_SEPARATOR . str_replace(['\\', '_'], DIRECTORY_SEPARATOR, $class) . '.php'; - if (file_exists($file)) { - return $file; - } - } - - // This match FRSS model classes - $freshrssClass = str_replace('FreshRSS_', '', $class); - foreach ($this->searchPath as $path) { - $file = $path . DIRECTORY_SEPARATOR . str_replace(['\\', '_'], DIRECTORY_SEPARATOR, $freshrssClass) . '.php'; - if (file_exists($file)) { - return $file; - } - } - - // This match FRSS other classes - list(, $classType) = explode('_', $freshrssClass); - foreach ($this->searchPath as $path) { - $file = $path . DIRECTORY_SEPARATOR . $classType . 's' . DIRECTORY_SEPARATOR . str_replace('_', '', $freshrssClass) . '.php'; - if (file_exists($file)) { - return $file; - } - } - } - - /** - * Register the current loader in the autoload queue. - */ - public function register($prepend = false) { - spl_autoload_register([$this, 'loadClass'], true, $prepend); - } -} - -$loader = new ClassLoader(); -$loader->registerPath([ - APP_PATH, - APP_PATH . DIRECTORY_SEPARATOR . 'Models', - LIB_PATH, - LIB_PATH . DIRECTORY_SEPARATOR . 'SimplePie', -]); -$loader->register(); -- cgit v1.2.3