-
Notifications
You must be signed in to change notification settings - Fork 6
/
extend.php
61 lines (46 loc) · 1.9 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
<?php
/*
* This file is part of flarumite/simple-discussion-views.
*
* Copyright (c) 2020 Flarumite.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarumite\DiscussionViews;
use Flarum\Api\Controller;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Discussion\Discussion;
use Flarum\Discussion\Event\Saving;
use Flarum\Discussion\Filter\DiscussionFilterer;
use Flarum\Discussion\Search\DiscussionSearcher;
use Flarum\Extend;
return [
(new Extend\Frontend('forum'))
->css(__DIR__.'/resources/less/forum.less')
->js(__DIR__.'/js/dist/forum.js'),
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js'),
new Extend\Locales(__DIR__.'/resources/locale'),
(new Extend\Model(Discussion::class))
->cast('view_count', 'int'),
(new Extend\Event())
->listen(Saving::class, Listeners\SaveDiscussionFromModal::class),
(new Extend\ApiSerializer(DiscussionSerializer::class))
->attribute('views', function (DiscussionSerializer $serializer, Discussion $discussion) {
return $discussion->view_count;
})
->attributes(AddAttributesBasedOnPermission::class),
(new Extend\ApiController(Controller\ShowDiscussionController::class))
->prepareDataForSerialization(Listeners\AddDiscussionViewHandler::class),
(new Extend\ApiController(Controller\ListDiscussionsController::class))
->addSortField('view_count'),
(new Extend\Settings())
->default('fsdv.ignore-crawlers', true),
(new Extend\ServiceProvider())
->register(Provider\DiscussionViewsProvider::class),
(new Extend\SimpleFlarumSearch(DiscussionSearcher::class))
->addGambit(Search\PopularFilterGambit::class),
(new Extend\Filter(DiscussionFilterer::class))
->addFilter(Search\PopularFilterGambit::class),
];