public function install($app_id, $options = null, $auto_enable = 1) { $app = app::get($app_id); if (!file_exists(APP_DIR . '/' . $app_id . '/app.xml')) { if (!$this->download($app_id)) { logger::info('Application package can not be download.'); return false; } } if ($app_id != 'base' || app::get('base')->status() != 'uninstalled') { $rows = vmc::database()->select('select * from vmc_base_apps where app_id="' . $app_id . '"'); if (isset($rows[0]) && $rows[0]['status'] != 'uninstalled') { logger::info('Application package Already installed'); return false; } $app_self_detector = null; vmc::database()->exec('update vmc_base_apps set status="installing" where app_id="' . $app_id . '" and status="uninstalled" '); } $app->runtask('pre_install', $options); vmc::singleton('base_application_dbtable')->clear_by_app($app_id); //清除冗余表信息 foreach ($this->content_detector($app_id) as $detector) { foreach ($detector->detect($app) as $name => $item) { $item->install(); } vmc::set_online(true); base_kvstore::instance('system')->store('service_last_modified.' . get_class($detector) . '.' . $app_id, $detector->last_modified($app_id)); } //todo:clear service cache... 如果以后做了缓存的话... //用自己新安装的资源探测器,安装自己的资源 foreach (vmc::servicelist('app_content_detector') as $k => $detector) { if ($detector->app->app_id == $app_id) { //遍历所有已经安装的app foreach ($detector->detect($app) as $name => $item) { $item->install(); } base_kvstore::instance('system')->store('service_last_modified.' . get_class($detector) . '.' . $app_id, $detector->last_modified($app_id)); } } app::get('base')->model('apps')->replace(array('status' => 'installed', 'app_id' => $app_id, 'dbver' => $app->define('version')), array('app_id' => $app_id)); $this->update_local_app_info($app_id); $app->runtask('post_install', $options); if ($auto_enable) { $this->enable($app_id); } logger::info('Application ' . $app_id . ' installed... ok.'); }
public function post_install() { vmc::singleton('base_application_manage')->sync(); vmc::set_online(true); }