1 | <?php |
||
16 | class Router { |
||
17 | private $handlers = array(); |
||
18 | private $hooks; |
||
19 | |||
20 | /** |
||
21 | * Constructor |
||
22 | * |
||
23 | * @param \Elgg\PluginHooksService $hooks For customized routing. |
||
24 | */ |
||
25 | 7 | public function __construct(\Elgg\PluginHooksService $hooks) { |
|
28 | |||
29 | /** |
||
30 | * Routes the request to a registered page handler |
||
31 | * |
||
32 | * This function triggers a plugin hook `'route', $identifier` so that plugins can |
||
33 | * modify the routing or handle a request. |
||
34 | * |
||
35 | * @param \Elgg\Http\Request $request The request to handle. |
||
36 | * @return boolean Whether the request was routed successfully. |
||
37 | * @access private |
||
38 | */ |
||
39 | 5 | public function route(\Elgg\Http\Request $request) { |
|
85 | |||
86 | /** |
||
87 | * Register a function that gets called when the first part of a URL is |
||
88 | * equal to the identifier. |
||
89 | * |
||
90 | * @param string $identifier The page type to handle |
||
91 | * @param string $function Your function name |
||
92 | * |
||
93 | * @return bool Depending on success |
||
94 | */ |
||
95 | 6 | public function registerPageHandler($identifier, $function) { |
|
103 | |||
104 | /** |
||
105 | * Unregister a page handler for an identifier |
||
106 | * |
||
107 | * @param string $identifier The page type identifier |
||
108 | * |
||
109 | * @return void |
||
110 | */ |
||
111 | 1 | public function unregisterPageHandler($identifier) { |
|
114 | |||
115 | /** |
||
116 | * Get page handlers as array of identifier => callback |
||
117 | * |
||
118 | * @return array |
||
119 | */ |
||
120 | 1 | public function getPageHandlers() { |
|
123 | } |
||
124 | |||
125 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.