1 | <?php |
||
9 | class Route extends EventEmitter |
||
10 | { |
||
11 | /** |
||
12 | * Regexp ready route |
||
13 | * @var String |
||
14 | */ |
||
15 | public $parsedRoute; |
||
16 | |||
17 | /** |
||
18 | * Route method type |
||
19 | * @var String |
||
20 | */ |
||
21 | public $method; |
||
22 | |||
23 | /** |
||
24 | * Route action |
||
25 | * @var Callable |
||
26 | */ |
||
27 | public $action; |
||
28 | |||
29 | /** |
||
30 | * Route uri |
||
31 | * @var String |
||
32 | */ |
||
33 | private $uri; |
||
34 | |||
35 | /** |
||
36 | * Route filters |
||
37 | * @var array |
||
38 | */ |
||
39 | private $filters = []; |
||
40 | |||
41 | /** |
||
42 | * @param String $method |
||
43 | * @param String $uri |
||
44 | * @param Callable $action |
||
45 | */ |
||
46 | public function __construct ($method, $uri, $action) |
||
52 | |||
53 | /** |
||
54 | * Create a new filter for current route |
||
55 | * |
||
56 | * @param String $param parameter to filter |
||
57 | * @param String $filter regexp to execute |
||
58 | * |
||
59 | * @return void |
||
60 | */ |
||
61 | public function where($param, $filter) |
||
71 | |||
72 | /** |
||
73 | * Helper to listing to after event |
||
74 | * |
||
75 | * @param Callable $callback |
||
76 | * @return Void |
||
77 | */ |
||
78 | public function after($callback) |
||
82 | |||
83 | /** |
||
84 | * Parse route uri |
||
85 | * |
||
86 | * @return void |
||
87 | */ |
||
88 | public function parse() |
||
99 | |||
100 | /** |
||
101 | * Check if uri is parsed |
||
102 | * |
||
103 | * @return boolean |
||
104 | */ |
||
105 | public function isParsed() |
||
109 | |||
110 | /** |
||
111 | * Run the current route |
||
112 | * |
||
113 | * @param \React\Http\Request $request |
||
114 | * @param \React\Restify\Response $response |
||
115 | * @param Callable $next |
||
116 | * |
||
117 | * @return Void |
||
118 | */ |
||
119 | public function run(Request $request, Response $response, $next) |
||
133 | } |
||
134 |