| 257 | | if ($class->hasMethod('_remap')) |
| 258 | | { |
| 259 | | // Make the arguments routed |
| 260 | | $arguments = array(Router::$method, Router::$arguments); |
| 261 | | |
| 262 | | // The method becomes part of the arguments |
| 263 | | array_unshift(Router::$arguments, Router::$method); |
| 264 | | |
| 265 | | // Set the method to _remap |
| 266 | | Router::$method = '_remap'; |
| 267 | | } |
| 268 | | elseif (Router::$method[0] != '_') |
| 269 | | { |
| 270 | | // Use the arguments normally |
| 271 | | $arguments = Router::$arguments; |
| 272 | | } |
| 273 | | |
| 274 | | if ($class->hasMethod(Router::$method)) |
| 275 | | { |
| 276 | | // Start validation of method |
| 277 | | $method = $class->getMethod(Router::$method); |
| 278 | | |
| 279 | | if ($method->isPrivate() OR $method->isProtected()) |
| 280 | | { |
| 281 | | // Method is invalid |
| 282 | | unset($method); |
| 283 | | } |
| 284 | | } |
| 285 | | |
| 286 | | if ( ! isset($method)) |
| 287 | | { |
| 288 | | if ($class->hasMethod('_default')) |
| 289 | | { |
| 290 | | // Make the arguments routed |
| 291 | | $arguments = array(Router::$method, Router::$arguments); |
| 292 | | |
| 293 | | // The method becomes part of the arguments |
| 294 | | array_unshift(Router::$arguments, Router::$method); |
| 295 | | |
| 296 | | // Set the method to _default |
| 297 | | Router::$method = '_default'; |
| 298 | | |
| 299 | | // Load method |
| 300 | | $method = $class->getMethod('_default'); |
| 301 | | } |
| 302 | | else |
| 303 | | { |
| 304 | | Event::run('system.404'); |
| 305 | | } |
| 306 | | } |
| 307 | | |
| | 268 | |
| | 269 | try |
| | 270 | { |
| | 271 | // Load the controller method |
| | 272 | $method = $class->getMethod(Router::$method); |
| | 273 | |
| | 274 | if ($method->isProtected() or $method->isPrivate()) |
| | 275 | { |
| | 276 | // Do not attempt to invoke protected methods |
| | 277 | throw new ReflectionException('protected controller method'); |
| | 278 | } |
| | 279 | |
| | 280 | // Default arguments |
| | 281 | $arguments = Router::$arguments; |
| | 282 | } |
| | 283 | catch (ReflectionException $e) |
| | 284 | { |
| | 285 | // Use __call instead |
| | 286 | $method = $class->getMethod('__call'); |
| | 287 | |
| | 288 | // Use arguments in __call format |
| | 289 | $arguments = array(Router::$method, Router::$arguments); |
| | 290 | } |