{
foreach ($this->routes as $route) {
$match = array();
- if ($route->matcher()->match($req->query, $match)) {
- return array($route, $match);
+ if (!$route->matcher()->match($req->query, $match))
+ continue;
+
+ $methods = $route->methods();
+ if ($methods && !in_array($req->method, $methods)) {
+ continue;
}
+
+ return array($route, $match);
}
return null;
}
}
return $controller === $this->controller() && $action === $this->action();
}
+
+ public function methods()
+ {
+ $methods = \PFF\Arr::get($this->params, 'method');
+
+ if (!$methods)
+ return null;
+
+ if (!is_array($methods))
+ $methods = array($methods);
+
+ return array_map('strtoupper', $methods);
+ }
}
abstract class IPF_Router_Shortcut extends Exception