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\Output\OutputPage; |
| 16 | use MediaWiki\Page\ProperPageIdentity; |
| 17 | use MediaWiki\Skin\Skin; |
| 18 | use MediaWiki\User\UserIdentity; |
| 19 | |
| 20 | class VisualEditorHookRunner implements |
| 21 | VisualEditorApiVisualEditorEditPreSaveHook, |
| 22 | VisualEditorApiVisualEditorEditPostSaveHook, |
| 23 | VisualEditorBeforeEditorHook |
| 24 | { |
| 25 | |
| 26 | public function __construct( private readonly HookContainer $hookContainer ) { |
| 27 | } |
| 28 | |
| 29 | /** @inheritDoc */ |
| 30 | public function onVisualEditorApiVisualEditorEditPreSave( |
| 31 | ProperPageIdentity $page, |
| 32 | UserIdentity $user, |
| 33 | string $wikitext, |
| 34 | array &$params, |
| 35 | array $pluginData, |
| 36 | array &$apiResponse |
| 37 | ) { |
| 38 | return $this->hookContainer->run( 'VisualEditorApiVisualEditorEditPreSave', [ |
| 39 | $page, |
| 40 | $user, |
| 41 | $wikitext, |
| 42 | &$params, |
| 43 | $pluginData, |
| 44 | &$apiResponse |
| 45 | ], [ 'abortable' => true ] ); |
| 46 | } |
| 47 | |
| 48 | /** @inheritDoc */ |
| 49 | public function onVisualEditorApiVisualEditorEditPostSave( |
| 50 | ProperPageIdentity $page, |
| 51 | UserIdentity $user, |
| 52 | string $wikitext, |
| 53 | array $params, |
| 54 | array $pluginData, |
| 55 | array $saveResult, |
| 56 | array &$apiResponse |
| 57 | ): void { |
| 58 | $this->hookContainer->run( 'VisualEditorApiVisualEditorEditPostSave', [ |
| 59 | $page, |
| 60 | $user, |
| 61 | $wikitext, |
| 62 | $params, |
| 63 | $pluginData, |
| 64 | $saveResult, |
| 65 | &$apiResponse |
| 66 | ], [ 'abortable' => false ] ); |
| 67 | } |
| 68 | |
| 69 | /** @inheritDoc */ |
| 70 | public function onVisualEditorBeforeEditor( |
| 71 | OutputPage $output, |
| 72 | Skin $skin |
| 73 | ): bool { |
| 74 | return $this->hookContainer->run( 'VisualEditorBeforeEditor', [ |
| 75 | $output, |
| 76 | $skin |
| 77 | ], [ 'abortable' => true ] ); |
| 78 | } |
| 79 | } |