-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathextend.php
executable file
·45 lines (38 loc) · 1.72 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
<?php
/*
* This file is part of therealsujitk/flarum-ext-gifs.
*
* Copyright (c) Sujit Kumar.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Therealsujitk\GIFs;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Extend;
use Flarum\Settings\SettingsRepositoryInterface;
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'),
new Extend\Locales(__DIR__ . '/resources/locale'),
(new Extend\ApiSerializer(ForumSerializer::class))
->attribute('therealsujitk-gifs.engine', function ($serializer, $model) {
$settings = resolve(SettingsRepositoryInterface::class);
return $settings->get('therealsujitk-gifs.engine', 'giphy');
})
->attribute('therealsujitk-gifs.api_key', function ($serializer, $model) {
$settings = resolve(SettingsRepositoryInterface::class);
return $settings->get('therealsujitk-gifs.api_key', null);
})
->attribute('therealsujitk-gifs.rating', function ($serializer, $model) {
$settings = resolve(SettingsRepositoryInterface::class);
return $settings->get('therealsujitk-gifs.rating', 'off');
}),
(new Extend\Routes('api'))
->get('/therealsujitk-gifs', 'therealsujitk-gifs.index', Controllers\ListGIFController::class)
->post('/therealsujitk-gifs', 'therealsujitk-gifs.store', Controllers\AddGIFController::class)
->delete('/therealsujitk-gifs/{id}', 'therealsujitk-gifs.delete', Controllers\RemoveGIFController::class)
];