-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathextend.php
executable file
·60 lines (47 loc) · 2.01 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
<?php
/*
* This file is part of fof/links.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FoF\Links;
use Flarum\Api\Controller\ShowForumController;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Extend;
use FoF\Links\Api\Controller;
use FoF\Links\Api\Serializer\LinkSerializer;
use FoF\Links\Event\PermissionChanged;
return [
new Extend\Locales(__DIR__.'/locale'),
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/less/forum.less'),
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js')
->css(__DIR__.'/less/admin.less'),
(new Extend\Routes('api'))
->post('/links', 'links.create', Controller\CreateLinkController::class)
->post('/links/order', 'links.order', Controller\OrderLinksController::class)
->patch('/links/{id}', 'links.update', Controller\UpdateLinkController::class)
->delete('/links/{id}', 'links.delete', Controller\DeleteLinkController::class)
->remove('permission')
->post('/permission', 'permission', Controller\SetPermissionController::class),
(new Extend\ApiSerializer(ForumSerializer::class))
->hasMany('links', LinkSerializer::class),
(new Extend\Event())
->listen(PermissionChanged::class, Listener\LinkPermissionChanged::class),
(new Extend\ApiController(ShowForumController::class))
->addInclude(['links', 'links.parent'])
->prepareDataForSerialization(LoadForumLinksRelationship::class),
(new Extend\Settings())
->registerLessConfigVar('fof-links-show-only-icons-on-mobile', 'fof-links.show_icons_only_on_mobile', function ($value) {
return $value ? 'true' : 'false';
}),
(new Extend\ModelVisibility(Link::class))
->scope(Access\ScopeLinkVisibility::class),
(new Extend\Policy())
->modelPolicy(Link::class, Access\LinkPolicy::class),
];