mirror of
https://github.com/flarum/core.git
synced 2025-07-20 16:21:18 +02:00
Use UrlGenerator over Application for base URL
We need to get rid of this god class, as Laravel's Application contract gets even bigger with 5.8. To avoid having to add all these methods, we should try to stop using it where we can.
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
namespace Flarum\Forum\Controller;
|
namespace Flarum\Forum\Controller;
|
||||||
|
|
||||||
use Flarum\Foundation\Application;
|
|
||||||
use Flarum\Http\SessionAuthenticator;
|
use Flarum\Http\SessionAuthenticator;
|
||||||
|
use Flarum\Http\UrlGenerator;
|
||||||
use Flarum\User\Command\ConfirmEmail;
|
use Flarum\User\Command\ConfirmEmail;
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
@@ -27,9 +27,9 @@ class ConfirmEmailController implements RequestHandlerInterface
|
|||||||
protected $bus;
|
protected $bus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Application
|
* @var UrlGenerator
|
||||||
*/
|
*/
|
||||||
protected $app;
|
protected $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SessionAuthenticator
|
* @var SessionAuthenticator
|
||||||
@@ -38,13 +38,13 @@ class ConfirmEmailController implements RequestHandlerInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Dispatcher $bus
|
* @param Dispatcher $bus
|
||||||
* @param Application $app
|
* @param UrlGenerator $url
|
||||||
* @param SessionAuthenticator $authenticator
|
* @param SessionAuthenticator $authenticator
|
||||||
*/
|
*/
|
||||||
public function __construct(Dispatcher $bus, Application $app, SessionAuthenticator $authenticator)
|
public function __construct(Dispatcher $bus, UrlGenerator $url, SessionAuthenticator $authenticator)
|
||||||
{
|
{
|
||||||
$this->bus = $bus;
|
$this->bus = $bus;
|
||||||
$this->app = $app;
|
$this->url = $url;
|
||||||
$this->authenticator = $authenticator;
|
$this->authenticator = $authenticator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +63,6 @@ class ConfirmEmailController implements RequestHandlerInterface
|
|||||||
$session = $request->getAttribute('session');
|
$session = $request->getAttribute('session');
|
||||||
$this->authenticator->logIn($session, $user->id);
|
$this->authenticator->logIn($session, $user->id);
|
||||||
|
|
||||||
return new RedirectResponse($this->app->url());
|
return new RedirectResponse($this->url->to('forum')->base());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
namespace Flarum\Forum\Controller;
|
namespace Flarum\Forum\Controller;
|
||||||
|
|
||||||
use Flarum\Foundation\Application;
|
|
||||||
use Flarum\Http\Exception\TokenMismatchException;
|
use Flarum\Http\Exception\TokenMismatchException;
|
||||||
use Flarum\Http\Rememberer;
|
use Flarum\Http\Rememberer;
|
||||||
use Flarum\Http\SessionAuthenticator;
|
use Flarum\Http\SessionAuthenticator;
|
||||||
@@ -29,11 +28,6 @@ class LogOutController implements RequestHandlerInterface
|
|||||||
{
|
{
|
||||||
use AssertPermissionTrait;
|
use AssertPermissionTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Application
|
|
||||||
*/
|
|
||||||
protected $app;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Dispatcher
|
* @var Dispatcher
|
||||||
*/
|
*/
|
||||||
@@ -60,7 +54,6 @@ class LogOutController implements RequestHandlerInterface
|
|||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Application $app
|
|
||||||
* @param Dispatcher $events
|
* @param Dispatcher $events
|
||||||
* @param SessionAuthenticator $authenticator
|
* @param SessionAuthenticator $authenticator
|
||||||
* @param Rememberer $rememberer
|
* @param Rememberer $rememberer
|
||||||
@@ -68,14 +61,12 @@ class LogOutController implements RequestHandlerInterface
|
|||||||
* @param UrlGenerator $url
|
* @param UrlGenerator $url
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Application $app,
|
|
||||||
Dispatcher $events,
|
Dispatcher $events,
|
||||||
SessionAuthenticator $authenticator,
|
SessionAuthenticator $authenticator,
|
||||||
Rememberer $rememberer,
|
Rememberer $rememberer,
|
||||||
Factory $view,
|
Factory $view,
|
||||||
UrlGenerator $url
|
UrlGenerator $url
|
||||||
) {
|
) {
|
||||||
$this->app = $app;
|
|
||||||
$this->events = $events;
|
$this->events = $events;
|
||||||
$this->authenticator = $authenticator;
|
$this->authenticator = $authenticator;
|
||||||
$this->rememberer = $rememberer;
|
$this->rememberer = $rememberer;
|
||||||
@@ -93,7 +84,7 @@ class LogOutController implements RequestHandlerInterface
|
|||||||
$session = $request->getAttribute('session');
|
$session = $request->getAttribute('session');
|
||||||
$actor = $request->getAttribute('actor');
|
$actor = $request->getAttribute('actor');
|
||||||
|
|
||||||
$url = Arr::get($request->getQueryParams(), 'return', $this->app->url());
|
$url = Arr::get($request->getQueryParams(), 'return', $this->url->to('forum')->base());
|
||||||
|
|
||||||
// If there is no user logged in, return to the index.
|
// If there is no user logged in, return to the index.
|
||||||
if ($actor->isGuest()) {
|
if ($actor->isGuest()) {
|
||||||
|
Reference in New Issue
Block a user