Use new Routes extender

This commit is contained in:
Franz Liedke 2018-02-08 18:10:17 +01:00
parent 51fc730082
commit c3ff9ad1d9
2 changed files with 10 additions and 38 deletions

View File

@ -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');
}
];

View File

@ -1,33 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* 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');
}
}