1
0
mirror of https://github.com/flarum/core.git synced 2025-07-23 09:41:26 +02:00
Files
php-flarum/src/Http/UrlGenerator.php
Franz Liedke 1d1cc9e443 Fix asset URL generation
This is important when Flarum is deployed in a subfolder.

Closes #291.
2015-08-29 22:38:31 +02:00

39 lines
743 B
PHP

<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Http;
use Flarum\Core;
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, '/');
return Core::url() . "/$path";
}
public function toAsset($path)
{
return Core::url() . "/assets/$path";
}
}