/** * Handles autoloading of classes that have been specified in autoload.ini. * * @param string A class name. * * @return void * * @author Sean Kerr (skerr@mojavi.org) * @since 3.0.0 */ function __autoload($class) { // this static variable is generated by the $config file below static $classes; if (!isset($classes)) { try { // include the list of autoload classes $config = ConfigCache::checkConfig('config/autoload.ini'); } catch (MojaviException $e) { $e->printStackTrace(); } catch (Exception $e) { // unknown exception $e = new MojaviException($e->getMessage()); $e->printStackTrace(); } require_once $config; } if (!isset($classes[$class])) { // unspecified class $error = 'Autoloading of class "%s" failed'; $error = sprintf($error, $class); $e = new AutoloadException($error); $e->printStackTrace(); } // class exists, let's include it require_once $classes[$class]; }
/** * This method automatically adds <code>spl_autoload_register()</code> to * find and load nonexistent classes. * * Usually, not used by end user. * * @param string name of the class to load * @return null */ public static function load($class) { if (class_exists($class, false)) { return; } foreach (self::$dirs as $d) { if (is_file($f = $d . '/' . $class . '.php') && is_readable($f)) { return require_once $f; } } if (class_exists('AutoloadException', false)) { $ex = new AutoloadException('Class "' . $class . '" not found'); $ex->setExtra('Relative paths', implode(', ', str_replace(self::$rd . '/', '', self::$dirs))); throw $ex; } else { die('Class "' . $class . '" not found' . PHP_EOL . 'Relative paths: ' . implode(', ', str_replace(self::$rd . '/', '', self::$dirs))); } }