コード例 #1
0
ファイル: controller.php プロジェクト: sook/drumon_framework
 /**
  * Proccess controller
  *
  * @return object Response
  */
 public function process()
 {
     $this->response->charset = $this->app->config['charset'];
     // Protect from CSRF
     if ($this->csrf_protection && $this->app->block_request($this->request)) {
         $this->request->params['_token'] = REQUEST_TOKEN;
         $this->render_error(401);
     }
     // Set default view to render
     $action_name = $this->request->action_name;
     $this->view->params = $this->params;
     $this->render(App::to_underscore(str_replace('_', '/', $this->request->controller_name)) . '/' . $this->request->action_name);
     // Get AppController variables
     $app_controller_vars = get_class_vars('AppController');
     // Merge AppController hooks with active controller
     $this->before_action = array_merge($app_controller_vars['before_action'], $this->before_action);
     $this->after_action = array_merge($app_controller_vars['after_action'], $this->after_action);
     // Execute before_actions
     $this->execute_methods($this->before_action);
     // Execute main action
     $this->{$action_name}();
     // Execute after_actions
     $this->execute_methods($this->after_action);
     // Add helpers in controller to App instace
     $this->app->add_helpers(array_merge($app_controller_vars['helpers'], $this->helpers));
     // Set response body
     $this->response->body = $this->view->process($this->layout, $this->content_for_layout, $this->app->helpers, $this->request);
     // Return a Response object
     return $this->response;
 }
コード例 #2
0
ファイル: IndexController.php プロジェクト: a707937337/cases
 public function test()
 {
     $view = View::make('index')->with('name', 'guan')->with('arr', array('wang', 'li', 'guan', 'sui'))->with('title', '我是中文');
     //$view = View::make('index');
     View::process($view);
 }