-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
extend.php
58 lines (45 loc) · 2.08 KB
/
extend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
* This file is part of fof/merge-discussions.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FoF\MergeDiscussions;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Database\AbstractModel;
use Flarum\Extend;
use Flarum\Http\Middleware\HandleErrors;
use FoF\MergeDiscussions\Events\DiscussionWasMerged;
use FoF\MergeDiscussions\Posts\DiscussionMergePost;
return [
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/resources/less/forum.less'),
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js'),
new Extend\Locales(__DIR__.'/resources/locale'),
(new Extend\Routes('api'))
->get('/discussions/{id}/merge', 'fof.merge-discussions.preview', Api\Controllers\MergePreviewController::class)
->post('/discussions/{id}/merge', 'fof.merge-discussions.run', Api\Controllers\MergeController::class),
(new Extend\Post())
->type(DiscussionMergePost::class),
(new Extend\Event())
->listen(DiscussionWasMerged::class, Listeners\CreatePostWhenMerged::class)
->listen(DiscussionWasMerged::class, Listeners\NotifyParticipantsWhenMerged::class),
(new Extend\ApiSerializer(DiscussionSerializer::class))
->attribute('canMerge', function (DiscussionSerializer $serializer, AbstractModel $discussion) {
return $serializer->getActor()->can('merge', $discussion);
}),
(new Extend\Settings())
->default('fof-merge-discussions.search_limit', 4)
->serializeToForum('fof-merge-discussions.search_limit', 'fof-merge-discussions.search_limit', 'intVal'),
(new Extend\View())
->namespace('fof-merge-discussions', __DIR__.'/resources/views'),
(new Extend\Notification())
->type(Notification\DiscussionMergedBlueprint::class, DiscussionSerializer::class, ['alert', 'email']),
(new Extend\Middleware('forum'))
->insertBefore(HandleErrors::class, Middleware\Redirection::class),
];