1 | <?php |
||
14 | class RouteCollector |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $prefix; |
||
20 | |||
21 | /** |
||
22 | * @var Route[]|RouteCollection |
||
23 | */ |
||
24 | protected $routes = []; |
||
25 | |||
26 | public function __construct($prefix = '') |
||
31 | |||
32 | /** |
||
33 | * 获取路由集合 |
||
34 | * |
||
35 | * @return RouteCollection |
||
36 | */ |
||
37 | public function getRoutes() |
||
41 | |||
42 | /** |
||
43 | * 创建一条 http get 路由 |
||
44 | * |
||
45 | * @param string $path |
||
46 | * @param string|callable $action |
||
47 | * @return Route |
||
48 | */ |
||
49 | public function get($path, $action) |
||
53 | |||
54 | /** |
||
55 | * 创建一条 http post 路由 |
||
56 | * |
||
57 | * @param string $path |
||
58 | * @param string|callable $action |
||
59 | * @return Route |
||
60 | */ |
||
61 | public function post($path, $action) |
||
65 | |||
66 | /** |
||
67 | * 创建一条 http delete 路由 |
||
68 | * |
||
69 | * @param string $path |
||
70 | * @param string|callable $action |
||
71 | * @return Route |
||
72 | */ |
||
73 | public function delete($path, $action) |
||
77 | |||
78 | /** |
||
79 | * 创建一条 http put/patch 路由 |
||
80 | * |
||
81 | * @param string $path |
||
82 | * @param string|callable $action |
||
83 | * @return Route |
||
84 | */ |
||
85 | public function put($path, $action) |
||
89 | |||
90 | /** |
||
91 | * 创建一条 http options 路由 |
||
92 | * |
||
93 | * @param string $path |
||
94 | * @param string|callable $action |
||
95 | * @return Route |
||
96 | */ |
||
97 | public function options($path, $action) |
||
101 | |||
102 | /** |
||
103 | * 创建一条 http 请求路由 |
||
104 | * |
||
105 | * @param string $path |
||
106 | * @param string|callable $action |
||
107 | * @param array|string $methods |
||
108 | * @return Route |
||
109 | */ |
||
110 | public function map($path, $action, $methods = []) |
||
118 | |||
119 | public function any($path, $action) |
||
123 | |||
124 | /** |
||
125 | * 创建一条通用前缀的路由组 |
||
126 | * |
||
127 | * @param string $prefix |
||
128 | * @param callable $callback |
||
129 | */ |
||
130 | public function prefix($prefix, callable $callback) |
||
136 | } |