-
Notifications
You must be signed in to change notification settings - Fork 3
/
extend.php
51 lines (44 loc) · 1.78 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
<?php
/*
* This file is part of serakoi/flarumstaffbadge.
*
* Copyright (c) 2021 Serakoi.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Serakoi\FlarumStaffBadge;
use Flarum\Extend;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\User\User;
use Flarum\Api\Event\Serializing;
use Flarum\User\Event\Saving;
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')
->css(__DIR__.'/resources/less/admin.less'),
new Extend\Locales(__DIR__.'/resources/locale'),
(new Extend\Event())
->listen(Saving::class, SaveStaffBadgeToDatabase::class),
(new Extend\ApiSerializer(UserSerializer::class))
->attribute('staffBadge', function ($serializer, $user) {
return $user->staffBadge;
})
->attribute('tagList', function ($serializer, $user) {
return $user->tagList;
})
->attribute('canEditStaffBadge', function ($serializer, $user) {
return $serializer->getActor()->can('serakoi-flarumstaffbadge.canEditStaffBadge', $user);
})
->attribute('canEditTagList', function ($serializer, $user) {
return $serializer->getActor()->can('serakoi-flarumstaffbadge.canEditTagList', $user);
}),
(new Extend\Settings)
->serializeToForum('staffBadgeTitle', 'serakoi-flarumstaffbadge.staffBadge')
->serializeToForum('staffBadgeColor', 'serakoi-flarumstaffbadge.staffBadgeTextColor')
->serializeToForum('staffBadgeBg', 'serakoi-flarumstaffbadge.staffBadgeTextBg')
];