|
@@ -107,11 +107,11 @@ discard block |
|
|
block discarded – undo |
|
107
|
107
|
|
|
108
|
108
|
public function route(Request $request) { |
|
109
|
109
|
|
|
110
|
|
- $method = (string) $request->getMethod(); |
|
|
110
|
+ $method = (string)$request->getMethod(); |
|
111
|
111
|
|
|
112
|
112
|
$methods = $this->configuration->get('allowed-http-methods'); |
|
113
|
113
|
|
|
114
|
|
- if (!empty($methods) && in_array($method, $methods) === false) { |
|
|
114
|
+ if ( !empty($methods) && in_array($method, $methods) === false ) { |
|
115
|
115
|
|
|
116
|
116
|
throw new DispatcherException("Method not allowed", 0, null, 405, array( |
|
117
|
117
|
"Allow" => implode(",", $methods) |
|
@@ -121,9 +121,9 @@ discard block |
|
|
block discarded – undo |
|
121
|
121
|
|
|
122
|
122
|
$this->setRequest($request); |
|
123
|
123
|
|
|
124
|
|
- if ($this->bypass_routing === false) { |
|
|
124
|
+ if ( $this->bypass_routing === false ) { |
|
125
|
125
|
|
|
126
|
|
- if (!$this->parse()) throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404); |
|
|
126
|
+ if ( !$this->parse() ) throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404); |
|
127
|
127
|
|
|
128
|
128
|
} |
|
129
|
129
|
|
|
@@ -135,10 +135,10 @@ discard block |
|
|
block discarded – undo |
|
135
|
135
|
|
|
136
|
136
|
$class = $this->route->getClassName(); |
|
137
|
137
|
|
|
138
|
|
- if (class_exists($class)) { |
|
|
138
|
+ if ( class_exists($class) ) { |
|
139
|
139
|
|
|
140
|
140
|
// All the route parameters are also added to the query parameters |
|
141
|
|
- foreach ($this->route->getRequestParameters() as $parameter => $value) { |
|
|
141
|
+ foreach ( $this->route->getRequestParameters() as $parameter => $value ) { |
|
142
|
142
|
$this->getRequest()->getQuery()->set($parameter, $value); |
|
143
|
143
|
} |
|
144
|
144
|
|
|
@@ -163,13 +163,13 @@ discard block |
|
|
block discarded – undo |
|
163
|
163
|
|
|
164
|
164
|
$this->setResponse($response); |
|
165
|
165
|
|
|
166
|
|
- if (is_null($this->route)) { |
|
|
166
|
+ if ( is_null($this->route) ) { |
|
167
|
167
|
|
|
168
|
168
|
throw new DispatcherException("Route has not been loaded!"); |
|
169
|
169
|
|
|
170
|
170
|
} |
|
171
|
171
|
|
|
172
|
|
- if ($this->bypass_service) { |
|
|
172
|
+ if ( $this->bypass_service ) { |
|
173
|
173
|
|
|
174
|
174
|
return; |
|
175
|
175
|
|
|
@@ -177,7 +177,7 @@ discard block |
|
|
block discarded – undo |
|
177
|
177
|
|
|
178
|
178
|
$service = $this->getServiceInstance(); |
|
179
|
179
|
|
|
180
|
|
- if (!is_null($service)) { |
|
|
180
|
+ if ( !is_null($service) ) { |
|
181
|
181
|
|
|
182
|
182
|
$result = ""; |
|
183
|
183
|
|
|
@@ -185,7 +185,7 @@ discard block |
|
|
block discarded – undo |
|
185
|
185
|
|
|
186
|
186
|
$methods = $service->getImplementedMethods(); |
|
187
|
187
|
|
|
188
|
|
- if (in_array($method, $methods)) { |
|
|
188
|
+ if ( in_array($method, $methods) ) { |
|
189
|
189
|
|
|
190
|
190
|
$callable = $service->getMethod($method); |
|
191
|
191
|
|
|
@@ -225,10 +225,10 @@ discard block |
|
|
block discarded – undo |
|
225
|
225
|
|
|
226
|
226
|
$path = urldecode($this->getRequest()->route()); |
|
227
|
227
|
|
|
228
|
|
- foreach ($this->table->getRoutes() as $regex => $value) { |
|
|
228
|
+ foreach ( $this->table->getRoutes() as $regex => $value ) { |
|
229
|
229
|
|
|
230
|
230
|
// The current uri is checked against all the global regular expressions associated with the routes |
|
231
|
|
- if (preg_match("/".$regex."/", $path, $matches)) { |
|
|
231
|
+ if ( preg_match("/".$regex."/", $path, $matches) ) { |
|
232
|
232
|
|
|
233
|
233
|
/* If a route is matched, all the bits of the route string are evalued in order to create |
|
234
|
234
|
* new query parameters which will be available for the service class |