Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
DiscussionToolsHandler | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
onDiscussionToolsAddOverflowMenuItems | |
100.00% |
9 / 9 |
|
100.00% |
1 / 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 | * |
17 | * @file |
18 | */ |
19 | |
20 | namespace MediaWiki\Extension\ReportIncident\Hooks\Handlers; |
21 | |
22 | use MediaWiki\Context\IContextSource; |
23 | use MediaWiki\Extension\DiscussionTools\Hooks\DiscussionToolsAddOverflowMenuItemsHook; |
24 | use MediaWiki\Extension\DiscussionTools\OverflowMenuItem; |
25 | use MediaWiki\Extension\ReportIncident\Services\ReportIncidentController; |
26 | |
27 | class DiscussionToolsHandler implements DiscussionToolsAddOverflowMenuItemsHook { |
28 | |
29 | private ReportIncidentController $controller; |
30 | |
31 | public function __construct( ReportIncidentController $controller ) { |
32 | $this->controller = $controller; |
33 | } |
34 | |
35 | /** @inheritDoc */ |
36 | public function onDiscussionToolsAddOverflowMenuItems( |
37 | array &$overflowMenuItems, |
38 | array &$resourceLoaderModules, |
39 | array $threadItemData, |
40 | IContextSource $contextSource |
41 | ) { |
42 | // Only add overflow menu link if the: |
43 | // * page is in a supported namespace, |
44 | // * link is to be shown to the current user, and |
45 | // * feature flag is enabled. |
46 | if ( $this->controller->shouldAddMenuItem( $contextSource ) ) { |
47 | $overflowMenuItems[] = new OverflowMenuItem( |
48 | 'reportincident', |
49 | 'flag', |
50 | $contextSource->msg( 'reportincident-report-btn-label' ), |
51 | 0, |
52 | [ 'thread-id' => $threadItemData['id'] ] |
53 | ); |
54 | $resourceLoaderModules[] = 'ext.reportIncident'; |
55 | } |
56 | } |
57 | } |