-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
extend.php
66 lines (53 loc) · 1.92 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 fof/sentry
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FoF\Sentry;
use Flarum\Extend as Flarum;
use Flarum\Frontend\Document;
use Flarum\Frontend\RecompileFrontendAssets;
use Flarum\Locale\LocaleManager;
use Flarum\Settings\Event\Saved;
use FoF\Sentry\Middleware\HandleErrorsWithSentry;
use Illuminate\Container\Container;
use Illuminate\Support\Str;
return [
(new Flarum\ServiceProvider())
->register(SentryServiceProvider::class),
(new Flarum\Frontend('forum'))
->css(__DIR__.'/resources/less/forum.less')
->content(Content\SentryJavaScript::class),
(new Flarum\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js')
->content(function (Document $document) {
$document->payload['hasExcimer'] = extension_loaded('excimer');
}),
new Flarum\Locales(__DIR__.'/resources/locale'),
(new Flarum\Middleware('forum'))
->add(HandleErrorsWithSentry::class),
(new Flarum\Middleware('admin'))
->add(HandleErrorsWithSentry::class),
(new Flarum\Middleware('api'))
->add(HandleErrorsWithSentry::class),
(new Flarum\Event())
->listen(Saved::class, function (Saved $event) {
foreach ($event->settings as $key => $setting) {
if (Str::startsWith($key, 'fof-sentry.javascript')) {
$container = Container::getInstance();
$recompile = new RecompileFrontendAssets(
$container->make('flarum.assets.forum'),
$container->make(LocaleManager::class)
);
$recompile->flush();
return;
}
}
}),
(new Flarum\Settings())
->default('fof-sentry.monitor_performance', 0),
];