-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
extend.php
55 lines (42 loc) · 1.62 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
<?php
/*
* This file is part of fof/frontpage.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FoF\FrontPage;
use Flarum\Api\Controller\ListDiscussionsController;
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'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/resources/less/forum.less'),
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js'),
new Extend\Locales(__DIR__.'/resources/locale'),
(new Extend\Event())
->listen(Saving::class, Listeners\SaveFrontToDatabase::class),
(new Extend\SimpleFlarumSearch(DiscussionSearcher::class))
->addGambit(Query\FrontFilterGambit::class),
(new Extend\Filter(DiscussionFilterer::class))
->addFilter(Query\FrontFilterGambit::class),
(new Extend\Model(Discussion::class))
->cast('frontdate', 'datetime')
->cast('frontpage', 'bool'),
(new Extend\ApiSerializer(DiscussionSerializer::class))
->attributes(Listeners\AddApiAttributes::class),
(new Extend\ApiController(ListDiscussionsController::class))
->addSortField('frontdate'),
(new Extend\ServiceProvider())
->register(Provider\FrontpageSortmapProvider::class),
(new Extend\Middleware('forum'))
->add(Middleware\AddFrontpageFilter::class),
];