-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextend.php
66 lines (54 loc) · 2.74 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
62
63
64
65
66
<?php
/*
* This file is part of blomstra/trello.
*
* Copyright (c) 2021 Blomstra Ltd.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Blomstra\Trello;
use Blomstra\Trello\Controllers\AddBoardController;
use Blomstra\Trello\Controllers\DeleteBoardController;
use Blomstra\Trello\Controllers\ListBoardLabelsController;
use Blomstra\Trello\Controllers\ListBoardLanesController;
use Blomstra\Trello\Controllers\ListBoardMembersController;
use Blomstra\Trello\Controllers\ListBoardsController;
use Blomstra\Trello\Providers\TrelloServiceProvider;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Discussion\Discussion;
use Flarum\Discussion\Event\Saving;
use Flarum\Extend;
return [
(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\Locales(__DIR__.'/locale'),
(new Extend\Routes('api'))
->get('/blomstra/trello/api-boards', 'blomstra::trello.boards-api.index', ListBoardsController::class)
->get('/blomstra/trello/api-boards/{board}/lanes', 'blomstra::trello.boards-api.lanes.index', ListBoardLanesController::class)
->get('/blomstra/trello/api-boards/{board}/labels', 'blomstra::trello.boards-api.labels.index', ListBoardLabelsController::class)
->get('/blomstra/trello/api-boards/{board}/members', 'blomstra::trello.boards-api.members.index', ListBoardMembersController::class)
->post('/blomstra/trello/boards', 'blomstra::trello.boards.store', AddBoardController::class)
->delete('/blomstra/trello/boards/{shortLink}', 'blomstra::trello.boards.destroy', DeleteBoardController::class),
(new Extend\ApiSerializer(DiscussionSerializer::class))
->attribute('trelloCardId', function (DiscussionSerializer $serializer, Discussion $discussion, array $attributes) {
return $discussion->trello_card_id;
})
->attribute('canAddToTrello', function (DiscussionSerializer $serializer, Discussion $discussion, array $attributes) {
return (bool) $serializer->getActor()->can('addToTrello', $discussion);
}),
(new Extend\ApiSerializer(ForumSerializer::class))
->attributes(TrelloAttributes::class),
(new Extend\Event())
->listen(Saving::class, Listener\SaveTrelloIdToDatabase::class),
(new Extend\ServiceProvider())
->register(TrelloServiceProvider::class),
(new Extend\Settings())
->default('blomstra-trello.last_used_lane_id', '')
->default('blomstra-trello.default_board_id', ''),
];