1
0
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:
Franz Liedke
2015-06-17 00:16:35 +02:00
parent b65d18ee7f
commit 33d663bc8e
12 changed files with 542 additions and 359 deletions

View File

@@ -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