Exemplo n.º 1
0
 private function _dispatch($controller, $actionName)
 {
     $className = $controller . 'Controller';
     $instance = new $className($this->_params);
     $action = "{$actionName}Action";
     if (strcmp(method_exists($instance, $action), '1') !== 0) {
         $errorController = new ErrorController();
         $errorController->error404("アクションが存在しません:【クラス】{$className} 【アクション】{$action}");
     }
     $instance->run($action, $actionName, $controller);
 }
Exemplo n.º 2
0
 /**
  * ファイルをロードする
  * 
  * @param string $className クラス名
  * @return ファイルをロードすればtrueを返す
  */
 public function autoLoad($className)
 {
     foreach ($this->_dirs as $dir) {
         $file = "{$dir}/{$className}.php";
         if (is_readable($file)) {
             require_once $file;
             return true;
         }
     }
     $errorController = new ErrorController();
     $errorController->error404("ファイルが存在しません:{$file}");
 }
Exemplo n.º 3
0
 public function run($action, $actionName, $route)
 {
     try {
         $this->_view->addTemplateDir("resources/templates/{$route}");
         $template = "{$actionName}.tpl";
         if (strcmp($this->_view->templateExists($template), '1') !== 0) {
             $errorController = new ErrorController();
             $errorController->error404("テンプレートファイルが存在しません:{$template}");
         }
         $this->{$action}();
         $this->_view->display($template);
     } catch (Exception $e) {
         $errorController = new ErrorController();
         $errorController->error500($e);
     }
 }