mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-21 22:08:41 +00:00
Allow string routing instead of only requests
This commit is contained in:
parent
672eec44e3
commit
a2c4619b21
|
|
@ -102,15 +102,26 @@ class Router
|
|||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @throws
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function route(RequestAbstract $request) : array
|
||||
public function route($request, string $verb = RouteVerb::GET) : array
|
||||
{
|
||||
if($request instanceof RequestAbstract) {
|
||||
$uri = $request->getUri();
|
||||
$verb = $request->getRouteVerb();
|
||||
} elseif(is_string($request)) {
|
||||
$uri = $request;
|
||||
} else {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
$bound = [];
|
||||
foreach ($this->routes as $route => $destination) {
|
||||
foreach ($destination as $d) {
|
||||
if ($this->match($route, $d['verb'], $request->getUri(), $request->getRouteVerb())) {
|
||||
if ($this->match($route, $d['verb'], $uri, $verb)) {
|
||||
$bound[] = ['dest' => $d['dest']];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user