Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
EchoHooksHandler
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 onBeforeCreateEchoEvent
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare( strict_types=1 );
4
5namespace MediaWiki\Extension\CampaignEvents\Hooks\Handlers;
6
7use EchoAttributeManager;
8use EchoUserLocator;
9use MediaWiki\Extension\CampaignEvents\Notifications\RegistrationNotificationPresentationModel;
10use MediaWiki\Extension\Notifications\Hooks\BeforeCreateEchoEventHook;
11
12class EchoHooksHandler implements BeforeCreateEchoEventHook {
13
14    private const REGISTRATION_NOTIFICATION_CATEGORY = 'campaign-events-notification-registration';
15
16    /**
17     * @param array &$notifications
18     * @param array &$notificationCategories
19     * @param array &$icons
20     */
21    public function onBeforeCreateEchoEvent(
22        array &$notifications,
23        array &$notificationCategories,
24        array &$icons
25    ): void {
26        global $wgNotifyTypeAvailabilityByCategory;
27        $wgNotifyTypeAvailabilityByCategory[ self::REGISTRATION_NOTIFICATION_CATEGORY ] = [
28            'web' => false,
29            'email' => true,
30            'push' => false,
31        ];
32
33        $notificationCategories[ self::REGISTRATION_NOTIFICATION_CATEGORY ] = [
34            'tooltip' => 'echo-pref-tooltip-' . self::REGISTRATION_NOTIFICATION_CATEGORY
35        ];
36
37        $notifications[ RegistrationNotificationPresentationModel::NOTIFICATION_NAME ] = [
38            'category' => self::REGISTRATION_NOTIFICATION_CATEGORY,
39            'group' => 'positive',
40            'section' => 'message',
41            'presentation-model' => RegistrationNotificationPresentationModel::class,
42            EchoAttributeManager::ATTR_LOCATORS => [
43                [
44                    [ EchoUserLocator::class, 'locateFromEventExtra' ],
45                    [ 'user' ]
46                ]
47            ],
48        ];
49
50        $icons[RegistrationNotificationPresentationModel::ICON_NAME]['path'] =
51            'CampaignEvents/resources/icons/calendar.svg';
52    }
53}