protected function addRoute($methods, $uri, $action, $controller) { $uri = empty($this->context->getConfig('BASE_PATH')) ? $this->cleanUri($uri) : $this->context->getConfig('BASE_PATH') . $this->cleanUri($uri); $controller = empty($this->context->getConfig('CONTROLLER_NAME_SPACE')) ? $controller : (strpos($controller, $this->context->getConfig('CONTROLLER_NAME_SPACE')) !== false ? $controller : $this->context->getConfig('CONTROLLER_NAME_SPACE') . $controller); $route = new Route($this, $methods, $uri, $action, $controller); if (!empty($this->middleWareStack)) { $route->mid(end($this->middleWareStack)); } foreach ($methods as $method) { $this->routes[$method][$uri] = $route; } return $route; }