Example #1
0
 protected function checkCallable($controller, $action)
 {/*{{{*/
     if (false == is_callable(array(Controller::buildClass($controller), $action)) &&
         false == is_callable(array(Controller::buildClass($controller), 'has__call')))
     {
         throw new RouterException('无法调用的controll/action组合('.$controller.'/'.$action.')');
     }
 }/*}}}*/
    private function dispatch()
    {/*{{{*/
        $this->router = $this->initRouter();
        $this->router->compile();
        $this->response->setRouter($this->router);
		$script_uri = $this->request->getEnv('SCRIPT_URI');
        if (NULL === $script_uri) //fix script_uri only in apache rewrite model
        {
			$tmpUri = explode('?', getenv('REQUEST_URI'));
			$script_uri = 'http://'.getenv('HTTP_HOST').$tmpUri[0];	//http only
		}
        $this->router->dispatch($this, $script_uri);
        $this->controllerClass = Controller::buildClass($this->controller);
        $this->response->hostname = $this->request->getEnv('HTTP_HOST');
        $this->request->controller = $this->controller;
        $this->request->action = $this->action;
    }/*}}}*/