mirror of
https://github.com/flarum/core.git
synced 2025-08-02 06:30:53 +02:00
Use new extenders (#30)
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
* LICENSE file that was distributed with this source code.
|
* LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Flarum\Api\Event\Serializing;
|
|
||||||
use Flarum\Extend;
|
use Flarum\Extend;
|
||||||
use Flarum\Post\Event\Posted;
|
use Flarum\Post\Event\Posted;
|
||||||
use Flarum\Pusher\Api\Controller\AuthController;
|
use Flarum\Pusher\Api\Controller\AuthController;
|
||||||
@@ -15,7 +14,6 @@ use Flarum\Pusher\Listener;
|
|||||||
use Flarum\Pusher\PusherNotificationDriver;
|
use Flarum\Pusher\PusherNotificationDriver;
|
||||||
use Flarum\Settings\SettingsRepositoryInterface;
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
use Illuminate\Contracts\Container\Container;
|
use Illuminate\Contracts\Container\Container;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(new Extend\Frontend('forum'))
|
(new Extend\Frontend('forum'))
|
||||||
@@ -33,7 +31,14 @@ return [
|
|||||||
(new Extend\Notification())
|
(new Extend\Notification())
|
||||||
->driver('pusher', PusherNotificationDriver::class),
|
->driver('pusher', PusherNotificationDriver::class),
|
||||||
|
|
||||||
function (Dispatcher $events, Container $container) {
|
(new Extend\Settings())
|
||||||
|
->serializeToForum('pusherKey', 'flarum-pusher.app_key')
|
||||||
|
->serializeToForum('pusherCluster', 'flarum-pusher.app_cluster'),
|
||||||
|
|
||||||
|
(new Extend\Event())
|
||||||
|
->listen(Posted::class, Listener\PushNewPost::class),
|
||||||
|
|
||||||
|
function (Container $container) {
|
||||||
$container->bind(Pusher::class, function ($app) {
|
$container->bind(Pusher::class, function ($app) {
|
||||||
$settings = $app->make(SettingsRepositoryInterface::class);
|
$settings = $app->make(SettingsRepositoryInterface::class);
|
||||||
|
|
||||||
@@ -50,8 +55,5 @@ return [
|
|||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$events->listen(Posted::class, Listener\PushNewPost::class);
|
|
||||||
$events->listen(Serializing::class, Listener\AddPusherApi::class);
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* For detailed copyright and license information, please view the
|
|
||||||
* LICENSE file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Pusher\Listener;
|
|
||||||
|
|
||||||
use Flarum\Api\Event\Serializing;
|
|
||||||
use Flarum\Api\Serializer\ForumSerializer;
|
|
||||||
use Flarum\Settings\SettingsRepositoryInterface;
|
|
||||||
|
|
||||||
class AddPusherApi
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var SettingsRepositoryInterface
|
|
||||||
*/
|
|
||||||
protected $settings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SettingsRepositoryInterface $settings
|
|
||||||
*/
|
|
||||||
public function __construct(SettingsRepositoryInterface $settings)
|
|
||||||
{
|
|
||||||
$this->settings = $settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(Serializing $event)
|
|
||||||
{
|
|
||||||
if ($event->isSerializer(ForumSerializer::class)) {
|
|
||||||
$event->attributes['pusherKey'] = $this->settings->get('flarum-pusher.app_key');
|
|
||||||
$event->attributes['pusherCluster'] = $this->settings->get('flarum-pusher.app_cluster');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user