-
Notifications
You must be signed in to change notification settings - Fork 1
/
extend.php
73 lines (60 loc) · 2.87 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
67
68
69
70
71
72
73
<?php
/*
* This file is part of blomstra/flarum-linear.
*
* Copyright (c) Blomstra.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Blomstra\Linear;
use Blomstra\Linear\Controllers\ListLabelsController;
use Blomstra\Linear\Controllers\ListPrioritiesController;
use Blomstra\Linear\Controllers\ListTeamsController;
use Blomstra\Linear\Controllers\CreateLinearIssueController;
use Blomstra\Linear\Providers\LinearIssuesServiceProvider;
use Blomstra\Linear\Providers\LinearLabelsServiceProvider;
use Blomstra\Linear\Providers\LinearTeamsServiceProvider;
use Blomstra\Linear\Providers\LinearPrioritiesServiceProvider;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Tags\Api\Serializer\TagSerializer;
use Flarum\Tags\Tag;
use Flarum\Tags\Event\Saving as TagSaving;
use Flarum\Discussion\Discussion;
use Flarum\Extend;
return [
(new Extend\Event)
->listen(TagSaving::class, Tags\Listeners\AssignLinearLabel::class),
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/resources/less/forum.less'),
(new Extend\Frontend('admin'))
->css(__DIR__.'/less/admin.less')
->js(__DIR__.'/js/dist/admin.js'),
new Extend\Locales(__DIR__.'/resources/locale'),
(new Extend\Routes('api'))
->get('/linear/teams', 'teams.list', ListTeamsController::class)
->get('/linear/priorities', 'priorities.list', ListPrioritiesController::class)
->post('/linear/issues', 'issues.create', CreateLinearIssueController::class)
->get('/linear/labels', 'labels.list', ListLabelsController::class),
(new Extend\ServiceProvider())
->register(LinearTeamsServiceProvider::class)
->register(LinearPrioritiesServiceProvider::class)
->register(LinearLabelsServiceProvider::class)
->register(LinearIssuesServiceProvider::class),
(new Extend\ApiSerializer(TagSerializer::class))
->attribute('linearLabelId', function (TagSerializer $serializer, Tag $tag, array $attributes) {
return $tag->linear_label_id;
}),
(new Extend\Settings)
->serializeToForum('blomstraLinearDefaultTeamId', 'blomstra-linear.default-team')
->serializeToForum('blomstraLinearLastTeamId', 'blomstra-linear.last-team-id')
->serializeToForum('blomstraLinearLastPriority', 'blomstra-linear.last-priority'),
(new Extend\ApiSerializer(DiscussionSerializer::class))
->attribute('linearIssueId', function (DiscussionSerializer $serializer, Discussion $discussion, array $attributes) {
return $discussion->linear_issue_id;
})
->attribute('canAddToLinear', function (DiscussionSerializer $serializer, Discussion $discussion, array $attributes) {
return (bool) $serializer->getActor()->can('addToLinear', $discussion);
}),
];