1
0
mirror of https://github.com/flarum/core.git synced 2025-05-04 22:55:33 +02:00
php-flarum/src/Http/UrlGenerator.php
Franz Liedke 33d663bc8e 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.
2015-06-17 00:16:35 +02:00

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";
}
}