mirror of
https://github.com/flarum/core.git
synced 2025-05-05 23:15:22 +02:00
#696 Added support for prefixes in AbstractUrlGenerator.
This commit is contained in:
parent
5bbcba6332
commit
096aae7919
@ -14,5 +14,8 @@ use Flarum\Http\AbstractUrlGenerator;
|
|||||||
|
|
||||||
class UrlGenerator extends AbstractUrlGenerator
|
class UrlGenerator extends AbstractUrlGenerator
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected $prefix = 'api';
|
protected $prefix = 'api';
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,11 @@ class AbstractUrlGenerator
|
|||||||
*/
|
*/
|
||||||
protected $path;
|
protected $path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $prefix = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Application $app
|
* @param Application $app
|
||||||
* @param RouteCollection $routes
|
* @param RouteCollection $routes
|
||||||
@ -67,12 +72,18 @@ class AbstractUrlGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the base URL.
|
* Generate a URL to base with UrlGenerator's prefix.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function toBase()
|
public function toBase()
|
||||||
{
|
{
|
||||||
return $this->app->url($this->path);
|
$base = $this->app->url($this->path);
|
||||||
|
|
||||||
|
if (empty($this->prefix)) {
|
||||||
|
return $base;
|
||||||
|
} else {
|
||||||
|
return $base . '/' . $this->prefix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user