<?php require __DIR__ . '/../assembly.php'; EnvSetupHelper::initForWeb(__DIR__ . '/../');
public function run() {/*{{{*/ try { $this->registerShutDown(); EnvSetupHelper::initForWeb($this->root_dir); BeanFinder::get('debug')->begin('time', '' ,true, true); $this->dispatch(); $this->initInterceptors(); $interceptors = $this->loadInterceptors(); $this->invokeBefore($interceptors); BeanFinder::get('debug')->appendDescription('WebApplication run => '.$this->controllerClass.'::'.$this->action); BeanFinder::get('debug')->begin('time', 'new "'.$this->controllerClass.'" and do action "'.$this->action.'"'); BeanFinder::get('debug')->addParams(array('request' => $this->request, 'response' => $this->response), true); $controller = new $this->controllerClass($this->request, $this->response); ob_start(); $result = null; if(false == $this->response->skipAction) { $result = $controller->{$this->action}($this->request, $this->response); } BeanFinder::get('debug')->end(); $result = (null==$result)?Controller::SUCCESS:$result; if ($this->response->hasRedirect()) { ob_end_clean(); $this->invokeAfter($interceptors); $this->response->sendHeaders(); BeanFinder::get('debug')->end()->refreshRemoteContext(); return; } if ($result == Controller::DIRECT_OUTPUT) { $this->response->sendHeaders(); ob_end_flush(); $this->invokeAfter($interceptors); BeanFinder::get('debug')->end()->clearDebugContextCookie(); return; } else if (false == $result) { $this->response->setFor404(); } BeanFinder::get('debug')->begin('time', 'view'); $this->randerView($result); BeanFinder::get('debug')->end(); $this->invokeAfter($interceptors); BeanFinder::get('debug')->end()->clearDebugContextCookie(); } catch (WebException $ex) { $this->response->setFor404(); //$this->log($ex); //非法url组合,需要捕获,输出404 $this->response->ex = $ex; $this->randerView(Controller::STATUS_404); BeanFinder::get('debug')->addParams($ex)->autoCloseNode()->clearDebugContextCookie(); } catch (SystemException $ex) { $this->response->setFor404(); $this->log($ex); BeanFinder::get('debug')->addParams($ex)->autoCloseNode()->clearDebugContextCookie(); if ($this->isDevEnv()) $this->response->ex = $ex; else $this->response->ex = new SystemException('系统错误'); $this->randerView(Controller::STATUS_404); } catch (CustomException $ex) { $this->response->setFor404(); $this->log($ex->errorMessage()); BeanFinder::get('debug')->addParams($ex)->autoCloseNode()->clearDebugContextCookie(); $this->response->ex = $ex; $this->randerView(); } catch (Exception $ex) { $this->response->setFor404(); $this->log($ex); BeanFinder::get('debug')->addParams($ex)->autoCloseNode()->clearDebugContextCookie(); $this->response->ex = $ex; $this->randerView(); } ob_end_flush(); BeanFinder::get('debug')->display(); }/*}}}*/