/**
  * forward<br/>
  * ex) $this->forward_to('/main/index/1');
  * @see public/codeseed.php 
  */
 public function forward_to($where)
 {
     // parse path
     $path = parse_url_path($where);
     if (empty($path[1])) {
         $path[1] = Config::get('default_controller');
     }
     if (empty($path[2])) {
         $path[2] = Config::get('default_action');
     }
     $controller_path = $path[1];
     $action_path = $path[2];
     if (file_exists(Config::get('help_dir') . '/' . $controller_path . '.php')) {
         require_once Config::get('help_dir') . '/' . $controller_path . '.php';
     }
     $controller_name = under_to_camel($controller_path . '_controller');
     $controller = new $controller_name();
     // reserve controller and action name
     $controller->controller_name = $this->controller_name;
     $controller->action_name = $this->action_name;
     // execute request
     call_user_func(array($controller, 'before_filter'));
     call_user_func_array(array($controller, $action_path), refine_params(array_slice($path, 3)));
     call_user_func(array($controller, 'after_filter'));
     if (file_exists(Config::get('view_dir') . '/' . $controller_path . '/' . $action_path . '.php')) {
         call_user_func_array(array($controller, 'load_view'), array($controller_path . '/' . $action_path));
     }
     $this->skip();
 }
Exemple #2
0
    if (empty($path[2])) {
        $path[2] = Config::get('default_action');
    }
    $controller_path = $path[1];
    $action_path = $path[2];
    if (file_exists(Config::get('help_dir') . '/' . $controller_path . '.php')) {
        require_once Config::get('help_dir') . '/' . $controller_path . '.php';
    }
    $controller_name = under_to_camel($controller_path . '_controller');
    $controller = new $controller_name();
    // set action name
    $controller->controller_name = $controller_name;
    $controller->action_name = $action_path;
    // execute request
    call_user_func(array($controller, 'before_filter'));
    call_user_func_array(array($controller, $action_path), refine_params(array_slice($path, 3)));
    call_user_func(array($controller, 'after_filter'));
    if (file_exists(Config::get('view_dir') . '/' . $controller_path . '/' . $action_path . '.php')) {
        call_user_func_array(array($controller, 'load_view'), array($controller_path . '/' . $action_path));
    }
} catch (Skip $e) {
} catch (DbError $e) {
    Log::error($e->getMessage());
    // TODO replace below
    //echobn("db errro occurs. refers to the application log.");
    echobn($e->getMessage());
} catch (Exception $e) {
    Log::error($e->getMessage());
    // TODO replace below
    //echobn("errro occurs. refers to the application log.");
    echobn($e->getMessage());