mirror of
https://github.com/flarum/core.git
synced 2025-07-26 11:10:41 +02:00
Revamp routing
All routes are now stored in a RouteCollection, which is then used for dispatching by the (reusable) RouterMiddleware. This change also entails moving all routes to the service providers. This may be changed again later, and is done for convenience reasons right now.
This commit is contained in:
@@ -4,17 +4,17 @@ namespace Flarum\Http;
|
||||
|
||||
class UrlGenerator implements UrlGeneratorInterface
|
||||
{
|
||||
protected $router;
|
||||
protected $routes;
|
||||
|
||||
|
||||
public function __construct(Router $router)
|
||||
public function __construct(RouteCollection $routes)
|
||||
{
|
||||
$this->router = $router;
|
||||
$this->routes = $routes;
|
||||
}
|
||||
|
||||
public function toRoute($name, $parameters = [])
|
||||
{
|
||||
$path = $this->router->getPath($name, $parameters);
|
||||
$path = $this->routes->getPath($name, $parameters);
|
||||
$path = ltrim($path, '/');
|
||||
|
||||
// TODO: Prepend real base URL
|
||||
|
Reference in New Issue
Block a user