mirror of
https://github.com/flarum/core.git
synced 2025-05-04 22:55:33 +02:00
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.
29 lines
513 B
PHP
29 lines
513 B
PHP
<?php
|
|
|
|
namespace Flarum\Http;
|
|
|
|
class UrlGenerator implements UrlGeneratorInterface
|
|
{
|
|
protected $routes;
|
|
|
|
|
|
public function __construct(RouteCollection $routes)
|
|
{
|
|
$this->routes = $routes;
|
|
}
|
|
|
|
public function toRoute($name, $parameters = [])
|
|
{
|
|
$path = $this->routes->getPath($name, $parameters);
|
|
$path = ltrim($path, '/');
|
|
|
|
// TODO: Prepend real base URL
|
|
return "/$path";
|
|
}
|
|
|
|
public function toAsset($path)
|
|
{
|
|
return "/$path";
|
|
}
|
|
}
|