예제 #1
0
 /**
  * 设置配置缓存
  * 
  * $alias和$append的关系如下:
  * <ul>
  * <li>如果没有设置$alias或是没有设置$cache,则将不保存数据</li>
  * <li>如果没有设置$append: 则将会以$alias为名将$data保存在缓存$cache中</li>
  * <li>如果设置了$append和$alias: 则先去从$cache中获得名为$append的缓存内容,并且将$data以$alias为键名保存到该缓存内容中,
  * 然后仍然以$append之名写回到$cache中</li>
  * </ul>
  * 
  * @param string $alias 配置文件的缓存别名
  * @param string $append 配置文件的追加的配置
  * @param AbstractWindCache $cache 配置文件使用的缓存介质
  * @return void
  */
 private function setCache($alias, $append, $cache, $data)
 {
     if ($append) {
         $this->configs[$alias] = $data;
         $cache->set($append, $this->configs);
     } else {
         $cache->set($alias, $data);
     }
 }
 /**
  * 创建并运行当前应用
  * 
  * 配合过滤链策略部署,可以通过{@see AbstractWindFrontController::registeFilter}
  * 方法注册过滤器,当应用被执行时会判断当前时候有初始化过滤链对象,并选择是否是通过过滤链方式执行应用
  * @return void
  */
 protected function _run()
 {
     $application = $this->createApplication();
     if ($this->_chain !== null) {
         $this->_chain->setCallBack(array($application, 'run'), array(true));
         $this->_chain->getHandler()->handle($this);
     } else {
         $application->run($application->getConfig('filters'));
     }
     restore_error_handler();
     restore_exception_handler();
     $this->_app->getResponse()->sendResponse();
     $this->_app->getWindFactory()->executeDestroyMethod();
     if ($this->_cache !== null && $this->_cached === false) {
         $this->_cache->set('factory', $this->_factory);
         $this->_cache->set('classes', Wind::$_classes);
         $this->_cache->set('imports', Wind::$_imports);
         $this->_cache->set('config', $this->_config);
     }
 }