Example #1
0
 protected function createApplication($config, $factory)
 {
     $request = $factory->getInstance('request');
     $response = $factory->getInstance('response');
     $application = new WindWebApplication($request, $response, $factory);
     $response->setHeader('Content-type', 'text/html;charset=' . $config['charset']);
     $response->setCharset($config['charset']);
     $application->setConfig($config);
     return $application;
 }
 /**
  * Exception处理
  *
  * @param Exception $exception
  */
 public function _exceptionHandle($exception)
 {
     restore_exception_handler();
     /* @var $error WindError */
     $error = $this->_app->getFactory()->getInstance('error', array($this->_config['web-apps'][$this->_appName]['error-dir'], $this->_config['isclosed']));
     $error->exceptionHandle($exception);
 }
 /**
  * 创建并运行当前应用
  * 
  * 配合过滤链策略部署,可以通过{@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);
     }
 }
 protected function _createApplication()
 {
     $application = new WindWebApplication($this->getRequest(), $this->getFactory());
     $application->setDelayAttributes(array('dispatcher' => array('ref' => 'dispatcher'), 'handlerAdapter' => array('ref' => 'router')));
     return $application;
 }