mirror of
https://github.com/flarum/core.git
synced 2025-02-26 04:02:45 +01:00
Merge pull request #706 from Albert221/prefixes
#696 Added support for prefixes in AbstractUrlGenerator.
This commit is contained in:
commit
41ccade385
@ -14,5 +14,8 @@ use Flarum\Http\AbstractUrlGenerator;
|
||||
|
||||
class UrlGenerator extends AbstractUrlGenerator
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $prefix = 'api';
|
||||
}
|
||||
|
@ -30,6 +30,11 @@ class AbstractUrlGenerator
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = '';
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param RouteCollection $routes
|
||||
@ -67,12 +72,18 @@ class AbstractUrlGenerator
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base URL.
|
||||
* Generate a URL to base with UrlGenerator's prefix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
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