mirror of
https://github.com/flarum/framework.git
synced 2024-11-22 13:35:47 +08:00
Generate URL in the controller instead of the view
This commit is contained in:
parent
1ef9217f4d
commit
5b46ec801d
|
@ -13,6 +13,7 @@ namespace Flarum\Forum\Controller;
|
|||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Event\UserLoggedOut;
|
||||
use Flarum\Forum\UrlGenerator;
|
||||
use Flarum\Foundation\Application;
|
||||
use Flarum\Http\Controller\ControllerInterface;
|
||||
use Flarum\Http\Exception\TokenMismatchException;
|
||||
|
@ -55,9 +56,9 @@ class LogOutController implements ControllerInterface
|
|||
protected $view;
|
||||
|
||||
/**
|
||||
* @var SettingsRepositoryInterface
|
||||
* @var UrlGenerator
|
||||
*/
|
||||
protected $settings;
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
|
@ -65,7 +66,6 @@ class LogOutController implements ControllerInterface
|
|||
* @param SessionAuthenticator $authenticator
|
||||
* @param Rememberer $rememberer
|
||||
* @param Factory $view
|
||||
* @param SettingsRepositoryInterface $settings
|
||||
*/
|
||||
public function __construct(
|
||||
Application $app,
|
||||
|
@ -73,14 +73,14 @@ class LogOutController implements ControllerInterface
|
|||
SessionAuthenticator $authenticator,
|
||||
Rememberer $rememberer,
|
||||
Factory $view,
|
||||
SettingsRepositoryInterface $settings
|
||||
UrlGenerator $url
|
||||
) {
|
||||
$this->app = $app;
|
||||
$this->events = $events;
|
||||
$this->authenticator = $authenticator;
|
||||
$this->rememberer = $rememberer;
|
||||
$this->view = $view;
|
||||
$this->settings = $settings;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,9 +106,7 @@ class LogOutController implements ControllerInterface
|
|||
|
||||
if (array_get($request->getQueryParams(), 'token') !== $csrfToken) {
|
||||
$view = $this->view->make('flarum.forum::log-out')
|
||||
->with('csrfToken', $csrfToken)
|
||||
->with('forumTitle', $this->settings->get('forum_title'))
|
||||
->with('return', array_get($request->getQueryParams(), 'return'));
|
||||
->with('url', $this->url->toRoute('logout').'?token='.$csrfToken.($return ? '&return='.urlencode($return) : ''));
|
||||
|
||||
return new HtmlResponse($view->render());
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
@extends('flarum.forum::layouts.basic')
|
||||
@inject('url', 'Flarum\Forum\UrlGenerator')
|
||||
|
||||
@section('title', $translator->trans('core.views.log_out.title'))
|
||||
|
||||
@section('content')
|
||||
<p>{{ $translator->trans('core.views.log_out.log_out_confirmation', ['{forum}' => $forumTitle]) }}</p>
|
||||
<p>{{ $translator->trans('core.views.log_out.log_out_confirmation', ['{forum}' => $settings->get('forum_title')]) }}</p>
|
||||
|
||||
<p>
|
||||
<a href="{{ $url->toRoute('logout') }}?token={{ $csrfToken }}@if ($return)&return={{ urlencode($return) }}@endif" class="button">
|
||||
<a href="{{ $url }}" class="button">
|
||||
{{ $translator->trans('core.views.log_out.log_out_button') }}
|
||||
</a>
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue
Block a user