mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:35:01 +08:00
Use new Routes extender
This commit is contained in:
parent
51fc730082
commit
c3ff9ad1d9
|
@ -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');
|
||||
}
|
||||
];
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user