Route.php 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. declare(strict_types=1);
  12. namespace think\facade;
  13. use think\Facade;
  14. use think\route\Dispatch;
  15. use think\route\Domain;
  16. use think\route\Rule;
  17. use think\route\RuleGroup;
  18. use think\route\RuleItem;
  19. use think\route\RuleName;
  20. use think\route\Url as UrlBuild;
  21. /**
  22. * @see \think\Route
  23. * @package think\facade
  24. * @mixin \think\Route
  25. * @method static mixed config(string $name = null)
  26. * @method static \think\Route lazy(bool $lazy = true) 设置路由域名及分组(包括资源路由)是否延迟解析
  27. * @method static \think\Route mergeRuleRegex(bool $merge = true) 设置路由域名及分组(包括资源路由)是否合并解析
  28. * @method static void setGroup(RuleGroup $group) 设置当前分组
  29. * @method static RuleGroup getGroup(string $name = null) 获取指定标识的路由分组 不指定则获取当前分组
  30. * @method static \think\Route pattern(array $pattern) 注册变量规则
  31. * @method static \think\Route option(array $option) 注册路由参数
  32. * @method static Domain domain(string|array $name, mixed $rule = null) 注册域名路由
  33. * @method static array getDomains() 获取域名
  34. * @method static RuleName getRuleName() 获取RuleName对象
  35. * @method static \think\Route bind(string $bind, string $domain = null) 设置路由绑定
  36. * @method static array getBind() 读取路由绑定信息
  37. * @method static string|null getDomainBind(string $domain = null) 读取路由绑定
  38. * @method static RuleItem[] getName(string $name = null, string $domain = null, string $method = '*') 读取路由标识
  39. * @method static void import(array $name) 批量导入路由标识
  40. * @method static void setName(string $name, RuleItem $ruleItem, bool $first = false) 注册路由标识
  41. * @method static void setRule(string $rule, RuleItem $ruleItem = null) 保存路由规则
  42. * @method static RuleItem[] getRule(string $rule) 读取路由
  43. * @method static array getRuleList() 读取路由列表
  44. * @method static void clear() 清空路由规则
  45. * @method static RuleItem rule(string $rule, mixed $route = null, string $method = '*') 注册路由规则
  46. * @method static \think\Route setCrossDomainRule(Rule $rule) 设置跨域有效路由规则
  47. * @method static RuleGroup group(string|\Closure $name, mixed $route = null) 注册路由分组
  48. * @method static RuleItem any(string $rule, mixed $route) 注册路由
  49. * @method static RuleItem get(string $rule, mixed $route) 注册GET路由
  50. * @method static RuleItem post(string $rule, mixed $route) 注册POST路由
  51. * @method static RuleItem put(string $rule, mixed $route) 注册PUT路由
  52. * @method static RuleItem delete(string $rule, mixed $route) 注册DELETE路由
  53. * @method static RuleItem patch(string $rule, mixed $route) 注册PATCH路由
  54. * @method static RuleItem head(string $rule, mixed $route) 注册HEAD路由
  55. * @method static RuleItem options(string $rule, mixed $route) 注册OPTIONS路由
  56. * @method static Resource resource(string $rule, string $route) 注册资源路由
  57. * @method static RuleItem view(string $rule, string $template = '', array $vars = []) 注册视图路由
  58. * @method static RuleItem redirect(string $rule, string $route = '', int $status = 301) 注册重定向路由
  59. * @method static \think\Route rest(string|array $name, array|bool $resource = []) rest方法定义和修改
  60. * @method static array|null getRest(string $name = null) 获取rest方法定义的参数
  61. * @method static RuleItem miss(string|\Closure $route, string $method = '*') 注册未匹配路由规则后的处理
  62. * @method static Response dispatch(\think\Request $request, Closure|bool $withRoute = true) 路由调度
  63. * @method static Dispatch|false check() 检测URL路由
  64. * @method static Dispatch url(string $url) 默认URL解析
  65. * @method static UrlBuild buildUrl(string $url = '', array $vars = []) URL生成 支持路由反射
  66. * @method static RuleGroup __call(string $method, array $args) 设置全局的路由分组参数
  67. */
  68. class Route extends Facade
  69. {
  70. /**
  71. * 获取当前Facade对应类名(或者已经绑定的容器对象标识)
  72. * @access protected
  73. * @return string
  74. */
  75. protected static function getFacadeClass()
  76. {
  77. return 'route';
  78. }
  79. }