1 | <?php |
||
19 | class RouteCollection |
||
20 | { |
||
21 | /** |
||
22 | * Contains all routes |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | private $_routes = []; |
||
27 | |||
28 | /** |
||
29 | * Add route matched with GET method. |
||
30 | * Shortcut for createRoute function with preset GET method. |
||
31 | * |
||
32 | * @param mixed $route route definition |
||
33 | * @param mixed $handler handler that will be executed if the url will match the route |
||
34 | * |
||
35 | * @return self for fluent interface |
||
36 | */ |
||
37 | public function get($route, $handler) { |
||
42 | |||
43 | /** |
||
44 | * Add route matched with POST method. |
||
45 | * Shortcut for createRoute function with preset POST method. |
||
46 | * |
||
47 | * @param mixed $route route definition |
||
48 | * @param mixed $handler handler that will be executed if the url will match the route |
||
49 | * |
||
50 | * @return self for fluent interface |
||
51 | */ |
||
52 | public function post($route, $handler) { |
||
57 | |||
58 | /** |
||
59 | * Add route matched with DELETE method. |
||
60 | * Shortcut for createRoute function with preset DELETE method. |
||
61 | * |
||
62 | * @param mixed $route route definition |
||
63 | * @param mixed $handler handler that will be executed if the url will match the route |
||
64 | * |
||
65 | * @return self for fluent interface |
||
66 | */ |
||
67 | public function delete($route, $handler) { |
||
72 | |||
73 | /** |
||
74 | * Add route matched with PUT method. |
||
75 | * Shortcut for createRoute function with preset PUT method. |
||
76 | * |
||
77 | * @param mixed $route route definition |
||
78 | * @param mixed $handler handler that will be executed if the url will match the route |
||
79 | * |
||
80 | * @return self for fluent interface |
||
81 | */ |
||
82 | public function put($route, $handler) { |
||
87 | |||
88 | /** |
||
89 | * Add route that will be matched to any method. |
||
90 | * Shortcut for createRoute function with preset ANY method. |
||
91 | * |
||
92 | * @param mixed $route route definition |
||
93 | * @param mixed $handler handler that will be executed if the url will match the route |
||
94 | * |
||
95 | * @return self for fluent interface |
||
96 | */ |
||
97 | public function any($route, $handler) { |
||
102 | |||
103 | /** |
||
104 | * Create a route to the collection. |
||
105 | * The data structure used in the $handler depends on the used dispatcher. |
||
106 | * |
||
107 | * @param mixed $method HTTP method that will be used for binding |
||
108 | * @param mixed $route route definition |
||
109 | * @param mixed $handler handler that will be executed if the url will match the route |
||
110 | * |
||
111 | * @return self for fluent interface |
||
112 | */ |
||
113 | public function createRoute($method, $route, $handler) { |
||
118 | |||
119 | /** |
||
120 | * Add a route to the collection. |
||
121 | * |
||
122 | * @param Kambo\Router\Route\Route $route route that will be added into collection |
||
123 | * |
||
124 | * @return self for fluent interface |
||
125 | */ |
||
126 | public function addRoute(Route $route) { |
||
131 | |||
132 | /** |
||
133 | * Get all defines routes in collection. |
||
134 | * |
||
135 | * @return Route[] |
||
136 | */ |
||
137 | public function getRoutes() { |
||
140 | } |