self::$cacheUpdated = true; return true; } } if (strpos($namespace, 'Hawk\\Plugins\\') === 0) { // If the class is an hawk class called from a plugin , // create an alias from the Hawk class to the plugin namespace $alias = '\\Hawk\\' . $class; if (class_exists($alias) || trait_exists($alias)) { class_alias($alias, $classname); return true; } } } /** * Save the autoload cache at the end of a script processing. It is not registered any times it is updated, * to improve the performances of the application. */ public static function saveCache() { if (self::$cacheUpdated) { Cache::getInstance()->save(self::CACHE_FILE, '<?php return ' . var_export(self::$cache, true) . ';'); } } } // register autoload function spl_autoload_register('\\Hawk\\Autoload::load', true, false); // Save the autoload cache Event::on('process-end', function (Event $event) { Autoload::saveCache(); });