Debian Codegraph @

extensions/OATHAuth/src/Hook/EchoHandler.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\OATHAuth\Hook;
4
5 use MediaWiki\Extension\Notifications\AttributeManager;
6 use MediaWiki\Extension\Notifications\Hooks\BeforeCreateEchoEventHook;
7 use MediaWiki\Extension\Notifications\UserLocator;
8 use MediaWiki\Extension\OATHAuth\Notifications\DisablePresentationModel;
9 use MediaWiki\Extension\OATHAuth\Notifications\EnablePresentationModel;
10 use MediaWiki\Extension\OATHAuth\Notifications\RecoveryCodeCountPresentationModel;
11
12 /**
13 * Hooks from Echo extension,
14 * which is optional to use with this extension.
15 */
16 class EchoHandler implements BeforeCreateEchoEventHook {
17
18 /**
19 * Hook: BeforeCreateEchoEvent
20 *
21 * Configure our notification types. We don't register a category since
22 * these are all "system" messages that cannot be disabled.
23 *
24 * @param array &$notifications
25 * @param array &$notificationCategories
26 * @param array &$notificationIcons
27 */
28 public function onBeforeCreateEchoEvent(
29 array &$notifications, array &$notificationCategories, array &$notificationIcons
30 ) {
31 // message used: notification-header-oathauth-disable
32 $notifications['oathauth-disable'] = [
33 'category' => 'system',
34 'group' => 'negative',
35 'section' => 'alert',
36 'presentation-model' => DisablePresentationModel::class,
37 'canNotifyAgent' => true,
38 AttributeManager::ATTR_LOCATORS => [
39 [ [ UserLocator::class, 'locateEventAgent' ] ],
40 ],
41 ];
42
43 // message used: notification-header-oathauth-enable
44 $notifications['oathauth-enable'] = [
45 'category' => 'system',
46 'group' => 'positive',
47 'section' => 'alert',
48 'presentation-model' => EnablePresentationModel::class,
49 'canNotifyAgent' => true,
50 AttributeManager::ATTR_LOCATORS => [
51 [ [ UserLocator::class, 'locateEventAgent' ] ],
52 ],
53 ];
54
55 // message used: notification-header-oathauth-recoverycodes-count
56 $notifications['oathauth-recoverycodes-count'] = [
57 'category' => 'system',
58 'group' => 'negative',
59 'section' => 'alert',
60 'presentation-model' => RecoveryCodeCountPresentationModel::class,
61 'canNotifyAgent' => true,
62 'user-locators' => [ 'EchoUserLocator::locateEventAgent' ],
63 ];
64 }
65 }