public function render(View $view)
 {
     switch ($this->getViewType()) {
         case Action::VIEW_HTML:
             $this->render = new \ORC\MVC\Response\HTML($this->controller);
             break;
         case Action::VIEW_JSON:
             $this->render = new \ORC\MVC\Response\JSON($this->controller);
             break;
         case Action::VIEW_RAW:
             $this->render = new \ORC\MVC\Response\RAW($this->controller);
             break;
         case Action::VIEW_REDIRECT:
             //redirect already be handled in controller, so here should not be this option
             //break;
         //redirect already be handled in controller, so here should not be this option
         //break;
         default:
             throw new ViewNotFoundException('unknown view type from action');
             break;
     }
     ViewModel::getInstance()->registerAll();
     //load all data from model
     $this->content = $view->render();
     return $this->render->render();
 }
 public function getViewModel()
 {
     if (!isset($this->_viewModel)) {
         $this->_viewModel = \ORC\MVC\ViewModel::getInstance();
     }
     return $this->_viewModel;
 }
예제 #3
0
 public function render()
 {
     //add default raw js
     $viewModel = ViewModel::getInstance();
     $js = 'function site_config(key) {return {"base_url":"' . Config::getInstance()->get('main_server') . '","window_id":' . mt_rand(1, 1000000) . '}[key.toLowerCase()];}';
     $viewModel->addRawJs($js);
     $action = $this->_controller->getAction();
     //find the correct template
     $template = TemplateManager::getInstance()->findTemplate($action);
     return $template->render();
 }
예제 #4
0
 protected function getViewModel()
 {
     return ViewModel::getInstance();
 }