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;
 }