1 | <?php |
||
15 | class Collection |
||
16 | { |
||
17 | /** |
||
18 | * Contains all routes |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | private $routes = []; |
||
23 | |||
24 | /** |
||
25 | * Add route matched with GET method. |
||
26 | * Shortcut for createRoute function with preset GET method. |
||
27 | * |
||
28 | * @param mixed $route route definition |
||
29 | * @param mixed $handler handler that will be executed if the url match |
||
30 | * the route |
||
31 | * |
||
32 | * @return self for fluent interface |
||
33 | */ |
||
34 | public function get($route, $handler) |
||
40 | |||
41 | /** |
||
42 | * Add route matched with POST method. |
||
43 | * Shortcut for createRoute function with preset POST method. |
||
44 | * |
||
45 | * @param mixed $route route definition |
||
46 | * @param mixed $handler handler that will be executed if the url match |
||
47 | * the route |
||
48 | * |
||
49 | * @return self for fluent interface |
||
50 | */ |
||
51 | 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 match |
||
64 | * the route |
||
65 | * |
||
66 | * @return self for fluent interface |
||
67 | */ |
||
68 | public function delete($route, $handler) |
||
74 | |||
75 | /** |
||
76 | * Add route matched with PUT method. |
||
77 | * Shortcut for createRoute function with preset PUT method. |
||
78 | * |
||
79 | * @param mixed $route route definition |
||
80 | * @param mixed $handler handler that will be executed if the url match |
||
81 | * the route |
||
82 | * |
||
83 | * @return self for fluent interface |
||
84 | */ |
||
85 | public function put($route, $handler) |
||
91 | |||
92 | /** |
||
93 | * Add route that will be matched to any method. |
||
94 | * Shortcut for createRoute function with preset ANY method. |
||
95 | * |
||
96 | * @param mixed $route route definition |
||
97 | * @param mixed $handler handler that will be executed if the url match |
||
98 | * the route |
||
99 | * |
||
100 | * @return self for fluent interface |
||
101 | */ |
||
102 | public function any($route, $handler) |
||
108 | |||
109 | /** |
||
110 | * Create a route to the collection. |
||
111 | * The data structure used in the $handler depends on the used dispatcher. |
||
112 | * |
||
113 | * @param mixed $method HTTP method that will be used for binding |
||
114 | * @param mixed $route route definition |
||
115 | * @param mixed $handler handler that will be executed if the |
||
116 | * url matchs the route |
||
117 | * |
||
118 | * @return self for fluent interface |
||
119 | */ |
||
120 | public function createRoute($method, $route, $handler) |
||
126 | |||
127 | /** |
||
128 | * Add a route to the collection. |
||
129 | * |
||
130 | * @param Kambo\Router\Route\Route $route route that will be added into |
||
131 | * collection |
||
132 | * |
||
133 | * @return self for fluent interface |
||
134 | */ |
||
135 | public function addRoute(Route $route) |
||
141 | |||
142 | /** |
||
143 | * Get all defines routes in collection. |
||
144 | * |
||
145 | * @return Route[] |
||
146 | */ |
||
147 | public function getRoutes() |
||
151 | } |
||
152 |