Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
81.82% |
18 / 22 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
VisualEditorHookRunner | |
81.82% |
18 / 22 |
|
75.00% |
3 / 4 |
4.10 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
onVisualEditorApiVisualEditorEditPreSave | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
onVisualEditorApiVisualEditorEditPostSave | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
onVisualEditorBeforeEditor | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\VisualEditor; |
4 | |
5 | /** |
6 | * VisualEditorHookRunner |
7 | * |
8 | * @file |
9 | * @ingroup Extensions |
10 | * @copyright 2011-2021 VisualEditor Team and others; see AUTHORS.txt |
11 | * @license MIT |
12 | */ |
13 | |
14 | use MediaWiki\HookContainer\HookContainer; |
15 | use MediaWiki\Page\ProperPageIdentity; |
16 | use MediaWiki\User\UserIdentity; |
17 | use OutputPage; |
18 | use Skin; |
19 | |
20 | class VisualEditorHookRunner implements |
21 | VisualEditorApiVisualEditorEditPreSaveHook, |
22 | VisualEditorApiVisualEditorEditPostSaveHook, |
23 | VisualEditorBeforeEditorHook |
24 | { |
25 | |
26 | /** @var HookContainer */ |
27 | private $hookContainer; |
28 | |
29 | /** |
30 | * @param HookContainer $hookContainer |
31 | */ |
32 | public function __construct( HookContainer $hookContainer ) { |
33 | $this->hookContainer = $hookContainer; |
34 | } |
35 | |
36 | /** @inheritDoc */ |
37 | public function onVisualEditorApiVisualEditorEditPreSave( |
38 | ProperPageIdentity $page, |
39 | UserIdentity $user, |
40 | string $wikitext, |
41 | array &$params, |
42 | array $pluginData, |
43 | array &$apiResponse |
44 | ) { |
45 | return $this->hookContainer->run( 'VisualEditorApiVisualEditorEditPreSave', [ |
46 | $page, |
47 | $user, |
48 | $wikitext, |
49 | &$params, |
50 | $pluginData, |
51 | &$apiResponse |
52 | ], [ 'abortable' => true ] ); |
53 | } |
54 | |
55 | /** @inheritDoc */ |
56 | public function onVisualEditorApiVisualEditorEditPostSave( |
57 | ProperPageIdentity $page, |
58 | UserIdentity $user, |
59 | string $wikitext, |
60 | array $params, |
61 | array $pluginData, |
62 | array $saveResult, |
63 | array &$apiResponse |
64 | ): void { |
65 | $this->hookContainer->run( 'VisualEditorApiVisualEditorEditPostSave', [ |
66 | $page, |
67 | $user, |
68 | $wikitext, |
69 | $params, |
70 | $pluginData, |
71 | $saveResult, |
72 | &$apiResponse |
73 | ], [ 'abortable' => false ] ); |
74 | } |
75 | |
76 | /** @inheritDoc */ |
77 | public function onVisualEditorBeforeEditor( |
78 | OutputPage $output, |
79 | Skin $skin |
80 | ): bool { |
81 | return $this->hookContainer->run( 'VisualEditorBeforeEditor', [ |
82 | $output, |
83 | $skin |
84 | ], [ 'abortable' => true ] ); |
85 | } |
86 | } |