mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 06:50:36 +08:00
f255d318ef
Spent quite a while looking into the best solution here and ended up going with three separate classes. Thanks to @Luceos for the PR that got this rolling (#518). My reasoning is: - The task of routing and URL generation is independent for each section of the app. Take Flarum\Api\Users\IndexAction for example. I don't want to generate a URL to a Flarum route... I specifically want to generate a URL to an API route. So there should be a class with that specific responsibility. - In fact, each URL generator is slightly different, because we need to add a certain prefix to the start (e.g. /api) - This also allows us to get rid of the "flarum.api" prefix on each route's name. - It's still DRY, because they all extend a base class. At the same time, I could see no reason this needed to be "interfaced", so all of the classes are concrete. Goes a long way to fixing #123 - still just a few places left remaining with hardcoded URLs.
21 lines
565 B
PHP
21 lines
565 B
PHP
<?php
|
|
$url = app('Flarum\Forum\UrlGenerator');
|
|
?>
|
|
<div class="container">
|
|
<h2>All Discussions</h2>
|
|
|
|
<ul>
|
|
@foreach ($document->data as $discussion)
|
|
<li>
|
|
<a href="{{ $url->toRoute('discussion', [
|
|
'id' => $discussion->id . '-' . $discussion->attributes->title
|
|
]) }}">
|
|
{{ $discussion->attributes->title }}
|
|
</a>
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
|
|
<a href="{{ $url->toRoute('index') }}?page={{ $page + 1 }}">Next Page »</a>
|
|
</div>
|