diff options
| author | 2020-12-26 06:47:39 -0500 | |
|---|---|---|
| committer | 2020-12-26 12:47:39 +0100 | |
| commit | 46cb89adf842e2fbac254fc99355d6577e4e86eb (patch) | |
| tree | fde13083862e0762b46250a3aafbf8788c5ba640 /lib/lib_rss.php | |
| parent | abfbeb6b71a5144145bd39beb6b774e1fce0c94b (diff) | |
Extract autoloading process (#3283)
* Extract autoloading process
The process sits in its own file now to ease future improvements.
* Change the autoload process
Before, the autoload process was too restricted. It was really dependant on our
code tree. It was hard to add more classes to be loaded automatically. On top
of that, it did not support autoloading classes following the PSR-4 recommendation.
Now, the autoload process is more open. It supports partially the PSR-4 recommendation,
there is no specific code to load Minz classes or PHPMailer classes. This is the
starting point to reorganize the codebase to introduce long waiting changes as seen
in #789. It would be a nice to later rework the tree, rename classes, and add namespace
in a fashion that follows the PSR-4. Then specific FRSS workarounds in the autoload
could be dropped.
Diffstat (limited to 'lib/lib_rss.php')
| -rw-r--r-- | lib/lib_rss.php | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 64f12c633..1ee054c14 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -15,6 +15,8 @@ if (COPY_SYSLOG_TO_STDERR) { openlog('FreshRSS', LOG_CONS | LOG_ODELAY | LOG_PID, LOG_USER); } +require_once LIB_PATH . DIRECTORY_SEPARATOR . 'autoload.php'; + /** * Build a directory path by concatenating a list of directory names. * @@ -26,33 +28,6 @@ function join_path() { return join(DIRECTORY_SEPARATOR, $path_parts); } -//<Auto-loading> -function classAutoloader($class) { - if (strpos($class, 'FreshRSS') === 0) { - $components = explode('_', $class); - switch (count($components)) { - case 1: - include(APP_PATH . '/' . $components[0] . '.php'); - return; - case 2: - include(APP_PATH . '/Models/' . $components[1] . '.php'); - return; - case 3: //Controllers, Exceptions - include(APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php'); - return; - } - } elseif (strpos($class, 'Minz') === 0) { - include(LIB_PATH . '/' . str_replace('_', '/', $class) . '.php'); - } elseif (strpos($class, 'SimplePie') === 0) { - include(LIB_PATH . '/SimplePie/' . str_replace('_', '/', $class) . '.php'); - } elseif (strpos($class, 'PHPMailer') === 0) { - include(LIB_PATH . '/' . str_replace('\\', '/', $class) . '.php'); - } -} - -spl_autoload_register('classAutoloader'); -//</Auto-loading> - function idn_to_puny($url) { if (function_exists('idn_to_ascii')) { $idn = parse_url($url, PHP_URL_HOST); |
