diff --git a/src/Forum/Controller/LogInController.php b/src/Forum/Controller/LogInController.php index 27a905fab..587e01693 100644 --- a/src/Forum/Controller/LogInController.php +++ b/src/Forum/Controller/LogInController.php @@ -16,6 +16,7 @@ use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; use Flarum\User\Event\LoggedIn; use Flarum\User\UserRepository; +use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Support\Arr; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; @@ -38,6 +39,11 @@ class LogInController implements RequestHandlerInterface */ protected $authenticator; + /** + * @var Dispatcher + */ + protected $events; + /** * @var Rememberer */ @@ -49,11 +55,12 @@ class LogInController implements RequestHandlerInterface * @param SessionAuthenticator $authenticator * @param Rememberer $rememberer */ - public function __construct(UserRepository $users, Client $apiClient, SessionAuthenticator $authenticator, Rememberer $rememberer) + public function __construct(UserRepository $users, Client $apiClient, SessionAuthenticator $authenticator, Dispatcher $events, Rememberer $rememberer) { $this->users = $users; $this->apiClient = $apiClient; $this->authenticator = $authenticator; + $this->events = $events; $this->rememberer = $rememberer; } @@ -76,7 +83,7 @@ class LogInController implements RequestHandlerInterface $token = AccessToken::find($data->token); - event(new LoggedIn($this->users->findOrFail($data->userId), $token)); + $this->events->dispatch(new LoggedIn($this->users->findOrFail($data->userId), $token)); if (Arr::get($body, 'remember')) { $response = $this->rememberer->remember($response, $token); diff --git a/src/Foundation/Console/CacheClearCommand.php b/src/Foundation/Console/CacheClearCommand.php index 5659976b2..85f526022 100644 --- a/src/Foundation/Console/CacheClearCommand.php +++ b/src/Foundation/Console/CacheClearCommand.php @@ -13,6 +13,7 @@ use Flarum\Console\AbstractCommand; use Flarum\Foundation\Event\ClearingCache; use Flarum\Foundation\Paths; use Illuminate\Contracts\Cache\Store; +use Illuminate\Contracts\Events\Dispatcher; class CacheClearCommand extends AbstractCommand { @@ -21,6 +22,11 @@ class CacheClearCommand extends AbstractCommand */ protected $cache; + /** + * @var Dispatcher + */ + protected $events; + /** * @var Paths */ @@ -30,9 +36,10 @@ class CacheClearCommand extends AbstractCommand * @param Store $cache * @param Paths $paths */ - public function __construct(Store $cache, Paths $paths) + public function __construct(Store $cache, Dispatcher $events, Paths $paths) { $this->cache = $cache; + $this->events = $events; $this->paths = $paths; parent::__construct(); @@ -62,6 +69,6 @@ class CacheClearCommand extends AbstractCommand array_map('unlink', glob($storagePath.'/locale/*')); array_map('unlink', glob($storagePath.'/views/*')); - event(new ClearingCache); + $this->events->dispatch(new ClearingCache); } } diff --git a/src/helpers.php b/src/helpers.php index d46660297..77ef27db1 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -29,6 +29,7 @@ if (! function_exists('app')) { if (! function_exists('event')) { /** + * @deprecated beta 16, removed in beta 17 * Fire an event and call the listeners. * * @param string|object $event