Skip to content

Commit 74f45c3

Browse files
committed
Update and fixed Router class.
1 parent 8088fd1 commit 74f45c3

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/Router.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ private function addRoute($uri, $method, $callback, $settings)
445445
*/
446446
private function beforeAfterCommand($command)
447447
{
448-
return RouterCommand::getInstance()->beforeAfter(
448+
return $this->routerCommand()->beforeAfter(
449449
$command, $this->middlewares[$command], $this->paths['middlewares'], $this->namespaces['middlewares']
450450
);
451451
}
@@ -457,7 +457,7 @@ private function beforeAfterCommand($command)
457457
*/
458458
private function runRouteCommand($command, $params = null)
459459
{
460-
RouterCommand::getInstance()->runRoute(
460+
$this->routerCommand()->runRoute(
461461
$command, $params, $this->paths['controllers'], $this->namespaces['controllers']
462462
);
463463
}
@@ -472,16 +472,16 @@ public function runRouteMiddleware($middleware, $type)
472472
if($type == 'before')
473473
{
474474
if(!is_null($middleware['group']))
475-
RouterCommand::getInstance()->beforeAfter($middleware['group'][$type], $this->middlewares, $this->paths['middlewares'], $this->namespaces['middlewares']);
475+
$this->routerCommand()->beforeAfter($middleware['group'][$type], $this->middlewares, $this->paths['middlewares'], $this->namespaces['middlewares']);
476476

477-
RouterCommand::getInstance()->beforeAfter($middleware[$type], $this->middlewares, $this->paths['middlewares'], $this->namespaces['middlewares']);
477+
$this->routerCommand()->beforeAfter($middleware[$type], $this->middlewares, $this->paths['middlewares'], $this->namespaces['middlewares']);
478478
}
479479
else
480480
{
481-
RouterCommand::getInstance()->beforeAfter($middleware[$type], $this->middlewares, $this->paths['middlewares'], $this->namespaces['middlewares']);
481+
$this->routerCommand()->beforeAfter($middleware[$type], $this->middlewares, $this->paths['middlewares'], $this->namespaces['middlewares']);
482482

483483
if(!is_null($middleware['group']))
484-
RouterCommand::getInstance()->beforeAfter($middleware['group'][$type], $this->middlewares, $this->paths['middlewares'], $this->namespaces['middlewares']);
484+
$this->routerCommand()->beforeAfter($middleware['group'][$type], $this->middlewares, $this->paths['middlewares'], $this->namespaces['middlewares']);
485485
}
486486
}
487487

@@ -527,4 +527,14 @@ public function exception($message = '')
527527
{
528528
return new RouterException($message);
529529
}
530+
531+
/**
532+
* RouterCommand class
533+
*
534+
* @return RouterCommand
535+
*/
536+
public function routerCommand($message = '')
537+
{
538+
return RouterCommand::getInstance();
539+
}
530540
}

0 commit comments

Comments
 (0)