From c3ff9ad1d9c450159b3141b842db0d061bf3aa12 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 8 Feb 2018 18:10:17 +0100 Subject: [PATCH] Use new Routes extender --- extensions/embed/bootstrap.php | 15 ++++++--- .../embed/src/Listener/AddEmbedRoute.php | 33 ------------------- 2 files changed, 10 insertions(+), 38 deletions(-) delete mode 100644 extensions/embed/src/Listener/AddEmbedRoute.php diff --git a/extensions/embed/bootstrap.php b/extensions/embed/bootstrap.php index bf472cd09..e8ef43f15 100644 --- a/extensions/embed/bootstrap.php +++ b/extensions/embed/bootstrap.php @@ -9,13 +9,18 @@ * file that was distributed with this source code. */ +use Flarum\Embed\EmbeddedDiscussionController; use Flarum\Embed\Listener; +use Flarum\Extend; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\View\Factory; -return function (Dispatcher $events, Factory $view) { - $events->subscribe(Listener\AddEmbedRoute::class); - $events->subscribe(Listener\FlushEmbedAssetsWhenSettingsAreChanged::class); +return [ + (new Extend\Routes('forum')) + ->get('/embed/{id:\d+(?:-[^/]*)?}[/{near:[^/]*}]', 'embed.discussion', EmbeddedDiscussionController::class), + function (Dispatcher $events, Factory $view) { + $events->subscribe(Listener\FlushEmbedAssetsWhenSettingsAreChanged::class); - $view->addNamespace('flarum-embed', __DIR__.'/views'); -}; + $view->addNamespace('flarum-embed', __DIR__.'/views'); + } +]; diff --git a/extensions/embed/src/Listener/AddEmbedRoute.php b/extensions/embed/src/Listener/AddEmbedRoute.php deleted file mode 100644 index da20d33ea..000000000 --- a/extensions/embed/src/Listener/AddEmbedRoute.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Embed\Listener; - -use Flarum\Event\ConfigureForumRoutes; -use Illuminate\Contracts\Events\Dispatcher; - -class AddEmbedRoute -{ - /** - * @param Dispatcher $events - */ - public function subscribe(Dispatcher $events) - { - $events->listen(ConfigureForumRoutes::class, [$this, 'addEmbedRoute']); - } - - /** - * @param ConfigureForumRoutes $event - */ - public function addEmbedRoute(ConfigureForumRoutes $event) - { - $event->get('/embed/{id:\d+(?:-[^/]*)?}[/{near:[^/]*}]', 'embed.discussion', 'Flarum\Embed\EmbeddedDiscussionController'); - } -}