Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
EchoNotificationsHandlers | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
onBeforeCreateEchoEvent | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
2 | |||
onEchoGetBundleRules | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Wikistories\Hooks; |
4 | |
5 | use MediaWiki\Extension\Notifications\AttributeManager; |
6 | use MediaWiki\Extension\Notifications\Model\Event; |
7 | use MediaWiki\Extension\Notifications\UserLocator; |
8 | use MediaWiki\Extension\Wikistories\Notifications\ArticleChangedPresentationModel; |
9 | |
10 | class EchoNotificationsHandlers { |
11 | |
12 | public const NOTIFICATION_TYPE = 'wikistories-articlechanged'; |
13 | |
14 | /** |
15 | * Handler for BeforeCreateEchoEvent hook |
16 | * @see https://www.mediawiki.org/wiki/Extension:Echo/BeforeCreateEchoEvent |
17 | * @see https://www.mediawiki.org/wiki/Notifications/Developer_guide |
18 | * |
19 | * @param array[] &$notifications |
20 | * @param array[] &$notificationCategories |
21 | * @param array[] &$icons |
22 | */ |
23 | public function onBeforeCreateEchoEvent( |
24 | array &$notifications, |
25 | array &$notificationCategories, |
26 | array &$icons |
27 | ) { |
28 | $notificationCategories[ 'wikistories-action' ] = [ |
29 | 'priority' => 5, |
30 | 'tooltip' => 'echo-pref-tooltip-wikistories-action', |
31 | ]; |
32 | |
33 | $notifications[ self::NOTIFICATION_TYPE ] = [ |
34 | AttributeManager::ATTR_LOCATORS => [ |
35 | UserLocator::class . '::locateUsersWatchingTitle', |
36 | ], |
37 | 'category' => 'wikistories-action', |
38 | 'group' => 'neutral', |
39 | 'section' => 'alert', |
40 | 'presentation-model' => ArticleChangedPresentationModel::class, |
41 | 'bundle' => [ 'web' => true, 'email' => true, 'expandable' => false ], |
42 | ]; |
43 | |
44 | $icons[ self::NOTIFICATION_TYPE ] = [ |
45 | 'path' => 'Wikistories/resources/images/edit.svg', |
46 | ]; |
47 | } |
48 | |
49 | /** |
50 | * @param Event $event |
51 | * @param string &$bundleString |
52 | */ |
53 | public function onEchoGetBundleRules( $event, &$bundleString ) { |
54 | if ( $event->getType() === self::NOTIFICATION_TYPE ) { |
55 | $bundleString = $event->getTitle()->getPrefixedDBkey(); |
56 | } |
57 | } |
58 | |
59 | } |