mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 12:43:52 +08:00
Use Routes extender
This commit is contained in:
parent
bb92a80585
commit
9480a26a84
|
@ -10,6 +10,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Flarum\Extend;
|
use Flarum\Extend;
|
||||||
|
use Flarum\Pusher\Api\Controller\AuthController;
|
||||||
use Flarum\Pusher\Listener;
|
use Flarum\Pusher\Listener;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
|
||||||
|
@ -21,6 +22,8 @@ return [
|
||||||
(new Extend\Assets('admin'))
|
(new Extend\Assets('admin'))
|
||||||
->asset(__DIR__.'/js/admin/dist/extension.js')
|
->asset(__DIR__.'/js/admin/dist/extension.js')
|
||||||
->bootstrapper('flarum/pusher/main'),
|
->bootstrapper('flarum/pusher/main'),
|
||||||
|
(new Extend\Routes('api'))
|
||||||
|
->post('/pusher/auth', 'pusher.auth', AuthController::class),
|
||||||
function (Dispatcher $events) {
|
function (Dispatcher $events) {
|
||||||
$events->subscribe(Listener\AddPusherApi::class);
|
$events->subscribe(Listener\AddPusherApi::class);
|
||||||
$events->subscribe(Listener\PushNewPosts::class);
|
$events->subscribe(Listener\PushNewPosts::class);
|
||||||
|
|
|
@ -13,8 +13,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\Event\ConfigureApiRoutes;
|
|
||||||
use Flarum\Pusher\Api\Controller\AuthController;
|
|
||||||
use Flarum\Settings\SettingsRepositoryInterface;
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
|
||||||
|
@ -39,7 +37,6 @@ class AddPusherApi
|
||||||
public function subscribe(Dispatcher $events)
|
public function subscribe(Dispatcher $events)
|
||||||
{
|
{
|
||||||
$events->listen(Serializing::class, [$this, 'addAttributes']);
|
$events->listen(Serializing::class, [$this, 'addAttributes']);
|
||||||
$events->listen(ConfigureApiRoutes::class, [$this, 'addRoutes']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,12 +49,4 @@ class AddPusherApi
|
||||||
$event->attributes['pusherCluster'] = $this->settings->get('flarum-pusher.app_cluster');
|
$event->attributes['pusherCluster'] = $this->settings->get('flarum-pusher.app_cluster');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ConfigureApiRoutes $event
|
|
||||||
*/
|
|
||||||
public function addRoutes(ConfigureApiRoutes $event)
|
|
||||||
{
|
|
||||||
$event->post('/pusher/auth', 'pusher.auth', AuthController::class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user