forked from FriendsOfFlarum/best-answer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extend.php
71 lines (58 loc) · 2.41 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
64
65
66
67
68
69
70
71
<?php
/*
* This file is part of fof/best-answer.
*
* 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\BestAnswer;
use Flarum\Api\Serializer\BasicDiscussionSerializer;
use Flarum\Discussion\Discussion;
use Flarum\Discussion\Event\Saving;
use Flarum\Event\ConfigureNotificationTypes;
use Flarum\Extend;
use Flarum\Foundation\Application;
use Flarum\Post\Post;
use Flarum\User\User;
use FoF\BestAnswer\Console\NotifyCommand;
use FoF\BestAnswer\Events\BestAnswerSet;
use FoF\BestAnswer\Listeners\AddGambits;
use FoF\BestAnswer\Provider\ConsoleProvider;
use FoF\Components\Extend\AddFofComponents;
use FoF\Console\Extend\EnableConsole;
use Illuminate\Contracts\Events\Dispatcher;
return [
new AddFofComponents(),
(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')
->css(__DIR__.'/resources/less/admin.less'),
new Extend\Locales(__DIR__.'/resources/locale'),
new EnableConsole(),
new DefaultSettings(),
(new Extend\Model(Discussion::class))
->belongsTo('bestAnswerPost', Post::class, 'best_answer_post_id')
->belongsTo('bestAnswerUser', User::class, 'best_answer_user_id'),
(new Extend\Console())
->command(NotifyCommand::class),
(new Extend\View())
->namespace('fof-best-answer', __DIR__.'/resources/views'),
function (Dispatcher $events) {
$events->subscribe(Listeners\AddApiAttributes::class);
$events->subscribe(AddGambits::class);
$events->listen(ConfigureNotificationTypes::class, function (ConfigureNotificationTypes $event) {
$event->add(Notification\SelectBestAnswerBlueprint::class, BasicDiscussionSerializer::class, ['alert', 'email']);
$event->add(Notification\AwardedBestAnswerBlueprint::class, BasicDiscussionSerializer::class, ['alert']);
$event->add(Notification\BestAnswerSetInDiscussionBlueprint::class, BasicDiscussionSerializer::class, []);
});
$events->listen(Saving::class, Listeners\SelectBestAnswer::class);
$events->listen(BestAnswerSet::class, Listeners\QueueNotificationJobs::class);
},
function (Application $app) {
$app->register(ConsoleProvider::class);
},
];