Add toUri function to router
This commit is contained in:
		| @@ -47,6 +47,17 @@ class GenericRouter implements RouterInterface | |||||||
|         throw new RouteNotFoundException($request); |         throw new RouteNotFoundException($request); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public function toUri(string $controller, string $method): string | ||||||
|  |     { | ||||||
|  |         foreach ($this->config->getRoutes() as $route) { | ||||||
|  |             if ($route->getController() === $controller && $route->getMethod() === $method) { | ||||||
|  |                 return $route->getRoute()->path; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         throw new \RuntimeException("Route for $controller::$method not found"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     private function resolveParams(string $routeUri, string $requestUri): ?array |     private function resolveParams(string $routeUri, string $requestUri): ?array | ||||||
|     { |     { | ||||||
|         if ($routeUri === $requestUri) { |         if ($routeUri === $requestUri) { | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ class BaseView implements ViewInterface | |||||||
|         include $path; |         include $path; | ||||||
|         $output = ob_get_clean(); |         $output = ob_get_clean(); | ||||||
|         if ($this->extends) { |         if ($this->extends) { | ||||||
|             $output = (new BaseView($this->extends, $this->data + ['slot' => $output]))->render($config); |             return (new BaseView($this->extends, $this->data + ['slot' => $output]))->render($config); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $output; |         return $output; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user