Пример #1
0
 /**
  * 调试应用
  *
  * @param unknown_type $alias        	
  * @param unknown_type $manifest        	
  */
 private function _upgrade($alias, $manifest)
 {
     // 更新基本信息
     Wind::import('APPCENTER:service.dm.PwApplicationDm');
     $man_array = $this->manifest->getManifest();
     $dm = new PwApplicationDm();
     $dm->setAppId($this->app_id);
     $dm->setName($man_array['application']['name']);
     $dm->setDescription($man_array['application']['description']);
     $dm->setVersion($man_array['application']['version']);
     $dm->setPwVersion($man_array['application']['pw-version']);
     $dm->setAuthorName($man_array['application']['author-name']);
     $dm->setAuthorEmail($man_array['application']['author-email']);
     $dm->setWebsite($man_array['application']['website']);
     $dm->setLogo($man_array['application']['logo']);
     Wekit::load('APPCENTER:service.PwApplication')->update($dm);
     $this->_loadPwHooks()->delByAppId($this->app_id);
     $this->_loadPwHookInject()->deleteByAppId($alias);
     $hooks = $this->manifest->getHooks();
     $log = array();
     if ($hooks) {
         foreach ($hooks as $key => $hook) {
             $hook['app_id'] = $this->app_id;
             $hook['app_name'] = $this->app['app_name'];
             $hooks[$key] = $hook;
         }
         $this->_loadPwHooks()->batchAdd($hooks);
         $log[] = array('app_id' => $this->app_id, 'log_type' => 'hook', 'data' => array_keys($hooks), 'created_time' => WEKIT_TIMESTAMP, 'modified_time' => WEKIT_TIMESTAMP);
     }
     $inject = $this->manifest->getInjectServices();
     if ($inject) {
         $inject_ids = array();
         foreach ($inject as $key => &$value) {
             $value['app_id'] = $alias;
             $value['app_name'] = $this->app['app_name'];
         }
         $this->_loadPwHookInject()->batchAdd($inject);
         $injects = $this->_loadPwHookInject()->findByAppId($alias);
         $log[] = array('app_id' => $this->app_id, 'log_type' => 'inject', 'data' => array_keys($injects), 'created_time' => WEKIT_TIMESTAMP, 'modified_time' => WEKIT_TIMESTAMP);
     }
     $log && $this->_loadInstallLog()->batchAdd($log);
 }
Пример #2
0
 /**
  * 注册应用信息
  *
  * @param PwInstallApplication $install        	
  * @return PwError true
  */
 public function registeApplication($install)
 {
     $manifest = $install->getManifest();
     $application = new PwApplicationDm();
     $application->setAppId($install->getAppId());
     $application->setName($manifest->getApplication('name'));
     $application->setAlias($manifest->getApplication('alias'));
     $application->setVersion($manifest->getApplication('version'));
     $application->setPwVersion($manifest->getApplication('pw-version'));
     $application->setDescription($manifest->getApplication('description'));
     $application->setLogo($manifest->getApplication('logo'));
     $application->setWebsite($manifest->getApplication('website'));
     $application->setAuthorName($manifest->getApplication('author-name'));
     $application->setAuthorEmail($manifest->getApplication('author-email'));
     $application->setAuthorIcon($manifest->getApplication('author-icon'));
     $application->setCreatedTime(Pw::getTime());
     $application->setModifiedTime(Pw::getTime());
     // 1 - 前台入口 2 - 后台入口 4 - 非纯在线 8 - 站内应用
     $status = 0;
     if ($tmp = $install->getTmpPackage()) {
         if (is_file($tmp . '/' . self::CONTROLLER)) {
             $status |= 1;
         }
         if (is_file($tmp . '/' . self::ADMIN)) {
             $status |= 2;
         }
         $status |= 4;
     }
     if ($install->getManifest()->getApplication('station', '0')) {
         $status |= 8;
     }
     $application->setStatus($status);
     if (!$application->beforeAdd()) {
         return new PwError('APPCENTER:install.mainfest.fail');
     }
     $this->_load()->add($application);
     $install->setInstallLog('appId', $install->getAppId());
     file_put_contents(DATA_PATH . 'tmp/log', 'app!', FILE_APPEND);
     return true;
 }