Exemple #1
0
/**
 * 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];
}