-
Notifications
You must be signed in to change notification settings - Fork 0
/
extend.php
63 lines (56 loc) · 2.62 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
59
60
61
62
63
<?php
/*
* This file is part of fof/byobu.
*
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FoF\Byobu;
use Flarum\Api\Serializer\BasicUserSerializer;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Event\ConfigureNotificationTypes;
use Flarum\Extend as Native;
use Flarum\Foundation\Application;
use FoF\Byobu\Notifications\DiscussionAddedBlueprint;
use FoF\Byobu\Notifications\DiscussionCreatedBlueprint;
use FoF\Byobu\Notifications\DiscussionRepliedBlueprint;
use Illuminate\Contracts\Events\Dispatcher;
return [
(new Native\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js'),
(new Native\Frontend('forum'))
->css(__DIR__.'/resources/less/forum/extension.less')
->js(__DIR__.'/js/dist/forum.js')
->content(Content\PassExtensionSettings::class),
new Native\Locales(__DIR__.'/resources/locale'),
new Extend\UserPreference('blocksPd', function ($value) {
return boolval($value);
}, false),
(new Extend\ApiAttribute())
->add(ForumSerializer::class, Api\PermissionAttributes::class)
->add(DiscussionSerializer::class, Api\PermissionAttributes::class)
->add(BasicUserSerializer::class, Api\UserAttributes::class),
new Native\Compat(function (Dispatcher $events) {
$events->subscribe(Listeners\AddGambits::class);
$events->subscribe(Listeners\AddRecipientsRelationships::class);
$events->subscribe(Listeners\CreatePostWhenRecipientsChanged::class);
$events->subscribe(Listeners\SaveRecipientsToDatabase::class);
$events->subscribe(Listeners\SaveBlocksPdPreference::class);
$events->subscribe(Listeners\SendPrivateDiscussionNotification::class);
$events->subscribe(Access\DiscussionPolicy::class);
// Support for fof/split
$events->subscribe(Listeners\AddRecipientsToSplitDiscussion::class);
// Add notifications
$events->listen(ConfigureNotificationTypes::class, function (ConfigureNotificationTypes $event) {
$event->add(DiscussionCreatedBlueprint::class, DiscussionSerializer::class, ['alert', 'email']);
$event->add(DiscussionRepliedBlueprint::class, DiscussionSerializer::class, ['alert', 'email']);
$event->add(DiscussionAddedBlueprint::class, DiscussionSerializer::class, ['alert']);
});
}),
function (Application $app) {
$app->register(Providers\ViewProvider::class);
},
];