/** * The actual autoloader * * @param string $className The name of the class to load * * @return void */ public function autoload_akeeba_engine($className) { // Trim the trailing backslash $className = ltrim($className, '\\'); // Make sure the class has an Akeeba\Engine prefix if (substr($className, 0, 13) != 'Akeeba\\Engine') { return; } // Remove the prefix and explode on backslashes $className = substr($className, 14); $class = explode('\\', $className); // Do we have a list of platform directories? if (is_null(self::$platformDirs) && class_exists('\\Akeeba\\Engine\\Platform', false)) { self::$platformDirs = Platform::getPlatformDirectories(); if (!is_array(self::$platformDirs)) { self::$platformDirs = array(); } } $rootPaths = array(self::$enginePath); if (is_array(self::$platformDirs)) { $rootPaths = array_merge(self::$platformDirs, array(self::$enginePath)); } foreach ($rootPaths as $rootPath) { // First try finding in structured directory format (preferred) $path = $rootPath . '/' . implode('/', $class) . '.php'; if (@file_exists($path)) { include_once $path; } // Then try the duplicate last name structured directory format (not recommended) if (!class_exists($className, false)) { reset($class); $lastPart = end($class); $path = $rootPath . '/' . implode('/', $class) . '/' . $lastPart . '.php'; if (@file_exists($path)) { include_once $path; } } } }