Ejemplo n.º 1
0
 /**
  * 应用程序执行
  *
  *
  * @return null
  */
 public static function run()
 {
     $className = application::getControllerName();
     $classPath = application::getControllerPath();
     $method = application::getControllerMethod();
     $arguments = router::arguments();
     //加载controller
     if (file_exists($classPath)) {
         zotop::load($classPath);
     } else {
         zotop::run('system.404', array('filepath' => $classPath));
         return false;
     }
     if (class_exists($className, false)) {
         $controller = new $className();
         if (method_exists($controller, $method) && $method[0] != '_') {
             call_user_func_array(array($controller, '__before'), $arguments);
             call_user_func_array(array($controller, $method), $arguments);
             call_user_func_array(array($controller, '__after'), $arguments);
             return true;
         }
         //当方法不存在时,默认调用类的_empty()函数,你可以在控制器中重写此方法
         return call_user_func_array(array($controller, '__empty'), array($method, $arguments));
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * 空动作,当找不到对应动作时候触发,可以被重载 
  *
  */
 public function __empty($method = '', $arguments = '')
 {
     msg::error(array('title' => '404 error', 'content' => zotop::t('<h2>未能找到相应的动作,请检查控制器中动作是否存在?</h2>控制器文件:{$file}<br>动作名称:{$method}', array('file' => application::getControllerPath(), 'method' => $method))));
 }