/** * 打包全部的hook文件 * */ public static function hooks() { $modules = zotop::data('module'); foreach ((array) $modules as $module) { if ((int) $module['status'] >= 0 && folder::exists($module['path'])) { //加载hook文件 runtime::$hooks[] = $module['path'] . DS . 'hooks' . DS . ZOTOP_APPLICATION_GROUP . '.php'; //加载库文件 zotop::register(@(include path::decode($module['path']) . DS . 'classes.php')); } } }
/** * 写入文件 * * @param string $file * @param string $content * @param boolean $overwrite * @return boolean */ public static function write($file, $content = '', $overwrite = TRUE) { $file = path::decode($file); //当目录不存在的情况下先创建目录 if (!folder::exists(dirname($file))) { folder::create(dirname($file)); } if (!file::exists($file) || $overwrite) { return @file_put_contents($file, $content); } return false; }
/** * 应用程序重启 * * * @return null */ public static function reboot() { //清理运行时文件 folder::clear(ZOTOP_PATH_RUNTIME); //加载全部配置 zotop::config(@(include ZOTOP_PATH_DATA . DS . 'config.php')); zotop::config('zotop.database', @(include ZOTOP_PATH_DATA . DS . 'database.php')); zotop::config('zotop.application', @(include ZOTOP_PATH_DATA . DS . 'application.php')); zotop::config('zotop.module', @(include ZOTOP_PATH_DATA . DS . 'module.php')); zotop::config('zotop.router', @(include ZOTOP_PATH_DATA . DS . 'router.php')); zotop::register(@(include ZOTOP_PATH_MODULES . DS . 'system' . DS . 'libraries.php')); zotop::register(@(include ZOTOP_PATH_APPLICATION . DS . 'libraries.php')); //加载全部开启模块的hook以及注册类文件 $modules = zotop::config('zotop.module'); foreach ((array) $modules as $module) { if ((int) $module['status'] >= 0 && folder::exists($module['path'])) { //加载库文件 zotop::register(@(include path::decode($module['path']) . DS . 'libraries.php')); //加载hook文件 application::$hooks[] = $module['path'] . DS . 'hooks' . DS . ZOTOP_APPLICATION . '.php'; } } //打包配置文件 zotop::data(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.config.php', zotop::config()); //打包hook文件 file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.hooks.php', application::compile(application::$hooks), true); //加载hooks以便核心文件使用 zotop::load(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.hooks.php'); //打包类文件 file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.core.php', application::compile(zotop::register()), true); }