Use Routes extender

This commit is contained in:
Franz Liedke 2018-02-08 18:25:58 +01:00
parent bb92a80585
commit 9480a26a84
2 changed files with 3 additions and 11 deletions

View File

@ -10,6 +10,7 @@
*/
use Flarum\Extend;
use Flarum\Pusher\Api\Controller\AuthController;
use Flarum\Pusher\Listener;
use Illuminate\Contracts\Events\Dispatcher;
@ -21,6 +22,8 @@ return [
(new Extend\Assets('admin'))
->asset(__DIR__.'/js/admin/dist/extension.js')
->bootstrapper('flarum/pusher/main'),
(new Extend\Routes('api'))
->post('/pusher/auth', 'pusher.auth', AuthController::class),
function (Dispatcher $events) {
$events->subscribe(Listener\AddPusherApi::class);
$events->subscribe(Listener\PushNewPosts::class);

View File

@ -13,8 +13,6 @@ namespace Flarum\Pusher\Listener;
use Flarum\Api\Event\Serializing;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Event\ConfigureApiRoutes;
use Flarum\Pusher\Api\Controller\AuthController;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Events\Dispatcher;
@ -39,7 +37,6 @@ class AddPusherApi
public function subscribe(Dispatcher $events)
{
$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');
}
}
/**
* @param ConfigureApiRoutes $event
*/
public function addRoutes(ConfigureApiRoutes $event)
{
$event->post('/pusher/auth', 'pusher.auth', AuthController::class);
}
}