DuckPhp\Helper\ControllerHelper

简介

控制器助手类

方法

助手类公开静态方法

助手类公开静态方法 IsDebug() IsRealDebug() Platform() Logger() trace_dump() var_dump(…$args)

超全局变量

GET($key, $default = null) POST($key, $default = null) REQUEST($key, $default = null) COOKIE($key, $default = null) 显示相关

H($str) L($str, $args = []) HL($str, $args = []) Display($view, $data = null) Show($data = [], $view = null) setViewHeadFoot($head_file = null, $foot_file = null) assignViewData($key, $value = null)

配置相关

Setting($key) Config($key, $file_basename = ‘config’) LoadConfig($file_basename)

路由相关

URL($url) Domain() ExitRedirect($url, $exit = true) ExitRedirectOutside($url, $exit = true) ExitRouteTo($url, $exit = true) Exit404($exit = true) ExitJson($ret, $exit = true) getParameters() getRouteCallingMethod() setRouteCallingMethod($method) getPathInfo()

系统兼容替换

header($output, bool $replace = true, int $http_response_code = 0) setcookie(string $key, string $value = ‘’, int $expire = 0, string $path = ‘/‘, string $domain = ‘’, bool $secure = false, bool $httponly = false) exit($code = 0)

SG($object=null)

异常处理

assignExceptionHandler($classes, $callback = null) setMultiExceptionHandler(array $classes, $callback) setDefaultExceptionHandler($callback)

分页相关

  • Pager($object = null)
  • PageNo()
  • PageSize($new_value = null)
  • PageHtml($total)

助手类公用方法列表

  • IsDebug()

    判断是否在调试状态,App 的 is_debug 选项 ,duckphp_is_debug 设置项。

  • IsRealDebug() 这个用于调试标识开,但是实际还是调试状态。用于特定用处。

  • Platform() 获得平台标志,App 的 platform 选项 ,duckphp_platform 设置项。

  • Logger($object=null) 返回Logger类。 $object 是替换入的新的 Logger 类。

  • trace_dump() 显示调用堆栈

  • var_dump(…$args) 替代 var_dump ,在非调试状态下不显示。

  • ThrowOn($flag, $message, $code = 0, $exception_class = null) 详见 Core/ThrowOn

    如果 $flag成立则抛出异常,如果未指定 $exception_class,抛则判断当前类是否是 Exception 类的子类,如果不是,则默认为 Exception 类。

  • AssignExtendStaticMethod($key, $value = null) 详见 Core/ExtendableStaticCallTrait 分配固定方法。

  • GetExtendStaticMethodList() 详见 Core/ExtendableStaticCallTrait 获得

  • __callStatic($name, $arguments) 详见 Core/ExtendableStaticCallTrait 静态方法已经被接管。

详解

额外单独扩展的方法

RecordsetUrl DuckPhp\Ext\Misc::RecordsetUrl

  1. DuckPhp\Ext\Misc::RecordsetUrl

RecordsetH

  1. DuckPhp\Ext\Misc::RecordsetH

CallAPI

  1. DuckPhp\Ext\Misc::CallAPI

assignRewrite

  1. DuckPhp\Ext\RouteHookRewrite::G::assignRewrite

getRewrites

  1. DuckPhp\Ext\RouteHookRewrite::G::getRewrites

getRoutes

  1. DuckPhp\Ext\RouteHookRouteMap::G::getRoutes

详解

Controller Helper 全是静态方法,调用 App 类的内容。

方法索引

  1. public static function Setting($key)
  2. public static function Config($key, $file_basename = 'config')
  3. public static function LoadConfig($file_basename)
  4. public static function H($str)
  5. public static function L($str, $args = [])
  6. public static function HL($str, $args = [])
  7. public static function Display($view, $data = null)
  8. public static function URL($url)
  9. public static function Domain()
  10. public static function getParameters()
  11. public static function getRouteCallingMethod()
  12. public static function setRouteCallingMethod($method)
  13. public static function getPathInfo()
  14. public static function Show($data = [], $view = null)
  15. public static function setViewHeadFoot($head_file = null, $foot_file = null)
  16. public static function assignViewData($key, $value = null)
  17. public static function ExitRedirect($url, $exit = true)
  18. public static function ExitRedirectOutside($url, $exit = true)
  19. public static function ExitRouteTo($url, $exit = true)
  20. public static function Exit404($exit = true)
  21. public static function ExitJson($ret, $exit = true)
  22. public static function header($output, bool $replace = true, int $http_response_code = 0)
  23. public static function setcookie(string $key, string $value = '', int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
  24. public static function exit($code = 0)
  25. public static function assignExceptionHandler($classes, $callback = null)
  26. public static function setMultiExceptionHandler(array $classes, $callback)
  27. public static function setDefaultExceptionHandler($callback)
  28. public static function SG()
  29. public static function GET($key, $default = null)
  30. public static function POST($key, $default = null)
  31. public static function REQUEST($key, $default = null)
  32. public static function COOKIE($key, $default = null)
  33. public static function Pager($object = null)
  34. public static function PageNo()
  35. public static function PageSize($new_value = null)
  36. public static function PageHtml($total)