-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextend.php
56 lines (44 loc) · 1.84 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
<?php
/*
* This file is part of datlechin/flarum-birthdays.
*
* Copyright (c) 2022 Ngo Quoc Dat.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Datlechin\Birthdays;
use Datlechin\Birthdays\Access\UserPolicy;
use Datlechin\Birthdays\Filter\BirthdayFilter;
use Datlechin\Birthdays\Listeners\AddUserBirthdayAttribute;
use Datlechin\Birthdays\Listeners\SaveBirthdayToDatabase;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\Extend;
use Flarum\User\Event\Saving;
use Flarum\User\Filter\UserFilterer;
use Flarum\User\User;
use Flarum\User\UserValidator;
return [
(new Extend\Frontend('forum'))
->route('/birthdays', 'birthdays')
->js(__DIR__ . '/js/dist/forum.js')
->css(__DIR__ . '/less/forum.less'),
(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js'),
new Extend\Locales(__DIR__ . '/locale'),
(new Extend\Event())
->listen(Saving::class, SaveBirthdayToDatabase::class),
(new Extend\ApiSerializer(UserSerializer::class))
->attributes(AddUserBirthdayAttribute::class),
(new Extend\Settings())
->serializeToForum('datlechin-birthdays.setBirthdayOnRegistration', 'datlechin-birthdays.set_on_registration', 'boolval')
->serializeToForum('datlechin-birthdays.dateFormat', 'datlechin-birthdays.date_format', 'strval')
->serializeToForum('datlechin-birthdays.dateNoneYearFormat', 'datlechin-birthdays.date_none_year_format', 'strval')
->default('datlechin-birthdays.min_age', 13),
(new Extend\Validator(UserValidator::class))
->configure(AddBirthdayValidation::class),
(new Extend\Policy())
->modelPolicy(User::class, UserPolicy::class),
(new Extend\Filter(UserFilterer::class))
->addFilter(BirthdayFilter::class),
];