-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathextend.php
61 lines (49 loc) · 2.12 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 webbinaro/flarum-calendar.
*
* Copyright (c) 2020 Eddie Webbinaro.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Webbinaro\AdvCalendar;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\Extend;
use Webbinaro\AdvCalendar\Api\Controllers as ControllersAlias;
use Webbinaro\AdvCalendar\Integrations\EventResourceRegister;
return [
(new Extend\Frontend('forum'))
->js(__DIR__ . '/js/dist/forum.js')
->css(__DIR__ . '/resources/less/forum.less')
->route('/events', 'advevents')
->route(
'/events/{id}[/{filter:[0-9]*}]',
'advevent',
Content\Event::class
),
(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js')
->css(__DIR__ . '/resources/less/admin.less'),
//API Routes
(new Extend\Routes('api'))
->get('/events', 'events.index', ControllersAlias\EventsListController::class)
->get('/events/{id}', 'events.show', ControllersAlias\EventsShowController::class)
->post('/events', 'events.create', ControllersAlias\EventsCreateController::class)
->patch('/events/{id}', 'events.edit', ControllersAlias\EventsUpdateController::class)
->delete('/events/{id}', 'events.delete', ControllersAlias\EventsDeleteController::class),
new Extend\Locales(__DIR__ . '/resources/locale'),
new EventResourceRegister(),
(new Extend\Settings)
->serializeToForum('webbinaro-calendar.hide_host', 'webbinaro-calendar.hide_host', 'boolval', false),
(new Extend\ApiSerializer(UserSerializer::class))
->attribute('canModerateEvents', function (UserSerializer $serializer) {
return $serializer->getActor()->can('event.moderate');
})
->attribute('canStartEvents', function (UserSerializer $serializer) {
return $serializer->getActor()->can('event.create');
})
->attribute('canViewEvents', function (UserSerializer $serializer) {
return $serializer->getActor()->can('event.view');
}),
];