1 | <?php |
||
9 | class CRouterBasic implements \Anax\DI\IInjectionAware |
||
10 | { |
||
11 | use \Anax\DI\TInjectionAware; |
||
12 | |||
13 | |||
14 | |||
15 | /** |
||
16 | * Properties |
||
17 | * |
||
18 | */ |
||
19 | private $routes = []; // All the routes |
||
20 | private $internalRoutes = []; // All internal routes |
||
21 | private $defaultRoute = null; // A default rout to catch all |
||
22 | |||
23 | |||
24 | |||
25 | /** |
||
26 | * Get all routes. |
||
27 | * |
||
28 | * @return array with all routes. |
||
29 | */ |
||
30 | public function getAll() |
||
34 | |||
35 | |||
36 | |||
37 | /** |
||
38 | * Get all internal routes. |
||
39 | * |
||
40 | * @return array with internal routes. |
||
41 | */ |
||
42 | public function getInternal() |
||
46 | |||
47 | |||
48 | |||
49 | /** |
||
50 | * Add a route to the router. |
||
51 | * |
||
52 | * @param string $rule for this route |
||
53 | * @param mixed $action null, string or callable to implement a controller for the route |
||
54 | * |
||
55 | * @return object as new route |
||
56 | */ |
||
57 | public function add($rule, $action = null) |
||
70 | |||
71 | |||
72 | |||
73 | /** |
||
74 | * Add an internal (not exposed to url-matching) route to the router. |
||
75 | * |
||
76 | * @param string $rule for this route |
||
77 | * @param mixed $action null, string or callable to implement a controller for the route |
||
78 | * |
||
79 | * @return object as new route |
||
80 | */ |
||
81 | public function addInternal($rule, $action = null) |
||
88 | |||
89 | |||
90 | /** |
||
91 | * Add an internal (not exposed to url-matching) route to the router. |
||
92 | * |
||
93 | * @param string $rule for this route |
||
94 | * |
||
95 | * @return object as new route |
||
96 | * @throws \Anax\Exception\NotFoundException |
||
97 | */ |
||
98 | public function handleInternal($rule) |
||
107 | |||
108 | |||
109 | /** |
||
110 | * Handle the routes and match them towards the request, dispatch them when a match is made. |
||
111 | * |
||
112 | * @return $this |
||
113 | * @throws \Anax\Exception\NotFoundException |
||
114 | * @throws \Exception |
||
115 | */ |
||
116 | public function handle() |
||
198 | } |
||
199 |