Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 30
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
CreateEchoEventHandler
0.00% covered (danger)
0.00%
0 / 30
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 / 30
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @since 0.0.1
20 */
21
22namespace MediaWiki\Extension\Adiutor\HookHandlers;
23
24use EchoAttributeManager;
25use EchoUserLocator;
26use MediaWiki\Extension\Adiutor\Presentations\EchoNotifyCreatorPresentationModel;
27use MediaWiki\Extension\Notifications\Hooks\BeforeCreateEchoEventHook;
28
29class CreateEchoEventHandler implements BeforeCreateEchoEventHook {
30    /**
31     * Add Adiutor events to Echo
32     *
33     * @param array &$notifications array of Echo notifications
34     * @param array &$notificationCategories array of Echo notification categories
35     * @param array &$notificationIcons array of icon details
36     */
37    public function onBeforeCreateEchoEvent(
38        array &$notifications,
39        array &$notificationCategories,
40        array &$notificationIcons
41    ) {
42        $notificationCategories['moderation'] = [
43            'priority' => 3,
44            'tooltip' => 'echo-pref-tooltip-moderation',
45        ];
46
47        $notifications['adiutor-csd-notification'] = [
48            'category' => 'adiutor',
49            'group' => 'positive',
50            'section' => 'alert',
51            'presentation-model' => EchoNotifyCreatorPresentationModel::class,
52            'bundle' => [
53                'web' => true,
54                'email' => true,
55                'expandable' => true,
56            ],
57            EchoAttributeManager::ATTR_LOCATORS => [
58                [
59                    [ EchoUserLocator::class, 'locateFromEventExtra' ],
60                    [ 'author' ]
61                ],
62            ],
63        ];
64
65        $notificationIcons['adiutor-notification-icon'] = [
66            'path' => [
67                'ltr' => 'Adiutor/resources/ext.adiutor.images/adiutor-notification-icon-ltr.svg',
68                'rtl' => 'Adiutor/resources/ext.adiutor.images/adiutor-notification-icon-rtl.svg'
69            ]
70        ];
71
72        $notificationIcons['adiutor-notification-icon-ltr'] = [
73            'path' => 'Adiutor/resources/ext.adiutor.images/adiutor-notification-icon-ltr.svg'
74        ];
75    }
76}