diff --git a/framework/core/src/Core/CoreServiceProvider.php b/framework/core/src/Core/CoreServiceProvider.php index 55833f4f1..d2cd86e78 100644 --- a/framework/core/src/Core/CoreServiceProvider.php +++ b/framework/core/src/Core/CoreServiceProvider.php @@ -72,6 +72,11 @@ class CoreServiceProvider extends ServiceProvider $this->app->singleton('flarum.formatter', 'Flarum\Core\Formatter\FormatterManager'); + $this->app->bind( + 'Flarum\Http\UrlGeneratorInterface', + 'Flarum\Http\UrlGenerator' + ); + $this->app->bind( 'Flarum\Core\Repositories\DiscussionRepositoryInterface', 'Flarum\Core\Repositories\EloquentDiscussionRepository' diff --git a/framework/core/src/Http/UrlGenerator.php b/framework/core/src/Http/UrlGenerator.php new file mode 100644 index 000000000..f712102cc --- /dev/null +++ b/framework/core/src/Http/UrlGenerator.php @@ -0,0 +1,28 @@ +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"; + } +} diff --git a/framework/core/src/Http/UrlGeneratorInterface.php b/framework/core/src/Http/UrlGeneratorInterface.php new file mode 100644 index 000000000..98851ea02 --- /dev/null +++ b/framework/core/src/Http/UrlGeneratorInterface.php @@ -0,0 +1,10 @@ +