forked from Ralkage/flarum-hcaptcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextend.php
48 lines (38 loc) · 1.58 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
<?php
/*
* This file is part of ralkage/flarum-hcaptcha.
*
* Copyright (c) Christian Lopez.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ralkage\HCaptcha;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Discussion\Event\Saving as DiscussionSaving;
use Flarum\Extend;
use Flarum\Post\Event\Saving as PostSaving;
use Flarum\User\Event\Saving as UserSaving;
use Ralkage\HCaptcha\Listeners\AddValidatorRule;
use Ralkage\HCaptcha\Validators\HCaptchaValidator;
return [
(new Extend\Frontend('forum'))
->js(__DIR__ . '/js/dist/forum.js')
->css(__DIR__ . '/resources/less/forum.less')
->content(Content\ExtensionSettings::class),
(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js'),
new Extend\Locales(__DIR__ . '/resources/locale'),
(new Extend\Settings())
->serializeToForum('hCaptchaDarkMode', 'hcaptcha-theme_dark_mode', 'boolVal'),
(new Extend\ApiSerializer(ForumSerializer::class))
->attribute('postWithoutHCaptcha', function (ForumSerializer $serializer) {
return $serializer->getActor()->hasPermission('ralkage-hcaptcha.postWithoutHCaptcha');
}),
(new Extend\Validator(HCaptchaValidator::class))
->configure(AddValidatorRule::class),
(new Extend\Event())
->listen(UserSaving::class, Listeners\RegisterValidate::class)
->listen(DiscussionSaving::class, Listeners\StartDiscussionValidate::class)
->listen(PostSaving::class, Listeners\ReplyPostValidate::class),
];