mirror of
https://github.com/flarum/core.git
synced 2025-08-06 16:36:47 +02:00
Get rid of event subscribers that resolve services too early, part 1
Refs flarum/core#1578.
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Flarum\Api\Event\Serializing;
|
||||||
use Flarum\Extend;
|
use Flarum\Extend;
|
||||||
use Flarum\Pusher\Api\Controller\AuthController;
|
use Flarum\Pusher\Api\Controller\AuthController;
|
||||||
use Flarum\Pusher\Listener;
|
use Flarum\Pusher\Listener;
|
||||||
@@ -26,7 +27,7 @@ return [
|
|||||||
->post('/pusher/auth', 'pusher.auth', AuthController::class),
|
->post('/pusher/auth', 'pusher.auth', AuthController::class),
|
||||||
|
|
||||||
function (Dispatcher $events) {
|
function (Dispatcher $events) {
|
||||||
$events->subscribe(Listener\AddPusherApi::class);
|
$events->listen(Serializing::class, Listener\AddPusherApi::class);
|
||||||
$events->subscribe(Listener\PushNewPosts::class);
|
$events->subscribe(Listener\PushNewPosts::class);
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@@ -14,7 +14,6 @@ namespace Flarum\Pusher\Listener;
|
|||||||
use Flarum\Api\Event\Serializing;
|
use Flarum\Api\Event\Serializing;
|
||||||
use Flarum\Api\Serializer\ForumSerializer;
|
use Flarum\Api\Serializer\ForumSerializer;
|
||||||
use Flarum\Settings\SettingsRepositoryInterface;
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
|
||||||
|
|
||||||
class AddPusherApi
|
class AddPusherApi
|
||||||
{
|
{
|
||||||
@@ -31,18 +30,7 @@ class AddPusherApi
|
|||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function handle(Serializing $event)
|
||||||
* @param Dispatcher $events
|
|
||||||
*/
|
|
||||||
public function subscribe(Dispatcher $events)
|
|
||||||
{
|
|
||||||
$events->listen(Serializing::class, [$this, 'addAttributes']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Serializing $event
|
|
||||||
*/
|
|
||||||
public function addAttributes(Serializing $event)
|
|
||||||
{
|
{
|
||||||
if ($event->isSerializer(ForumSerializer::class)) {
|
if ($event->isSerializer(ForumSerializer::class)) {
|
||||||
$event->attributes['pusherKey'] = $this->settings->get('flarum-pusher.app_key');
|
$event->attributes['pusherKey'] = $this->settings->get('flarum-pusher.app_key');
|
||||||
|
Reference in New Issue
Block a user