/**
  * 拦截器的执行入口
  * 
  * @param mixed $var=..
  *        该接口接受任意参数,并将依次传递给拦截器的前置和后置操作
  * @return mixed 返回拦截链执行的最终结果
  */
 public function handle($method)
 {
     if (method_exists($this, $method)) {
         $this->{$method}();
     }
     $handler = $this->interceptorChain->getHandler();
     if (null !== $handler) {
         $handler->handle($method);
     }
     return;
 }
예제 #2
0
 /**
  * 拦截器的执行入口
  * 
  * @param mixed $var=.. 该接口接受任意参数,并将依次传递给拦截器的前置和后置操作
  * @return mixed 返回拦截链执行的最终结果
  */
 public function handle()
 {
     $args = func_get_args();
     $this->result = call_user_func_array(array($this, 'preHandle'), $args);
     if ($this->result !== null) {
         return $this->result;
     }
     if (null !== ($handler = $this->interceptorChain->getHandler())) {
         $this->result = call_user_func_array(array($handler, 'handle'), $args);
     } else {
         $this->result = call_user_func_array(array($this->interceptorChain, 'handle'), $args);
     }
     call_user_func_array(array($this, 'postHandle'), $args);
     return $this->result;
 }
 /**
  * 创建并执行当前应用,单应用访问入口
  */
 public function run()
 {
     $this->_app = $this->createApplication($this->_config['web-apps'][$this->_appName], WindFactory::_getInstance());
     set_error_handler(array($this, '_errorHandle'), error_reporting());
     set_exception_handler(array($this, '_exceptionHandle'));
     if ($this->_config['isclosed']) {
         throw new Exception('Sorry, Site has been closed!');
     }
     if ($this->_chain !== null) {
         $this->_chain->getHandler()->handle('onCreate');
     }
     /* @var $router WindRouter */
     $router = $this->_app->getFactory()->getInstance('router');
     $router->route($this->_app->getRequest());
     if ($this->_chain !== null) {
         $this->_chain->getHandler()->handle('onStart');
     }
     $this->_app->run($router);
     if ($this->_chain !== null) {
         $this->_chain->getHandler()->handle('onResponse');
     }
     $this->_app->getResponse()->sendResponse();
     $this->_app->getFactory()->executeDestroyMethod();
     restore_error_handler();
     restore_exception_handler();
 }
예제 #4
0
 protected function doCompile($content, $windViewerResolver = null)
 {
     try {
         $content = $this->registerTags($content, $windViewerResolver);
         if ($this->windHandlerInterceptorChain !== null) {
             $this->windHandlerInterceptorChain->getHandler()->handle();
         }
         foreach (array_reverse($this->compiledBlockData) as $key => $value) {
             if (!$key) {
                 continue;
             }
             $content = str_replace($this->getBlockTag($key), $value ? $value : ' ', $content);
         }
         $content = preg_replace('/\\?>(\\s|\\n)*?<\\?php/i', "\r\n", $content);
         return $content;
     } catch (Exception $e) {
         throw new WindViewException('[component.viewer.WindViewTemplate.doCompile] compile fail.' . $e->getMessage(), WindViewException::ERROR_SYSTEM_ERROR);
     }
 }
예제 #5
0
 /**
  * 拦截器的执行入口
  * 
  * @param mixed $var=.. 该接口接受任意参数,并将依次传递给拦截器的前置和后置操作
  * @return mixed 返回拦截链执行的最终结果
  */
 public function handle($event, $targetObject = null)
 {
     $args = func_get_args();
     $_args = array_slice($args, 2);
     $this->targetObject = $targetObject;
     if (method_exists($this, 'pre' . $event)) {
         $this->result = call_user_func_array(array($this, 'pre' . $event), $_args);
         if (null !== $this->result) {
             return $this->result;
         }
     }
     if (null !== ($handler = $this->interceptorChain->getHandler())) {
         $this->result = call_user_func_array(array($handler, 'handle'), $args);
     } else {
         $this->result = call_user_func_array(array($this->interceptorChain, 'handle'), $_args);
     }
     if (method_exists($this, 'post' . $event)) {
         call_user_func_array(array($this, 'post' . $event), $_args);
     }
     return $this->result;
 }
 /**
  * 创建并运行当前应用
  * 
  * 配合过滤链策略部署,可以通过{@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);
     }
 }