1
0
mirror of https://github.com/flarum/core.git synced 2025-07-31 13:40:20 +02:00

Create URL generator interface.

Also bind a default implementation to the container.
This commit is contained in:
Franz Liedke
2015-05-27 23:58:43 +02:00
parent 7ab3437136
commit 9526dbf210
3 changed files with 43 additions and 0 deletions

28
src/Http/UrlGenerator.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
namespace Flarum\Http;
class UrlGenerator implements UrlGeneratorInterface
{
protected $router;
public function __construct(Router $router)
{
$this->router = $router;
}
public function toRoute($name, $parameters = [])
{
$path = $this->router->getPath($name, $parameters);
$path = ltrim($path, '/');
// TODO: Prepend real base URL
return "/$path";
}
public function toAsset($path)
{
return "/$path";
}
}