Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
84.00% |
21 / 25 |
|
80.00% |
4 / 5 |
CRAP | |
0.00% |
0 / 1 |
| VisualEditorHookRunner | |
84.00% |
21 / 25 |
|
80.00% |
4 / 5 |
5.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 | |||
| onVisualEditorRegisterChangeTags | |
100.00% |
3 / 3 |
|
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 | VisualEditorRegisterChangeTagsHook |
| 25 | { |
| 26 | |
| 27 | public function __construct( private readonly HookContainer $hookContainer ) { |
| 28 | } |
| 29 | |
| 30 | /** @inheritDoc */ |
| 31 | public function onVisualEditorApiVisualEditorEditPreSave( |
| 32 | ProperPageIdentity $page, |
| 33 | UserIdentity $user, |
| 34 | string $wikitext, |
| 35 | array &$params, |
| 36 | array $pluginData, |
| 37 | array &$apiResponse |
| 38 | ) { |
| 39 | return $this->hookContainer->run( 'VisualEditorApiVisualEditorEditPreSave', [ |
| 40 | $page, |
| 41 | $user, |
| 42 | $wikitext, |
| 43 | &$params, |
| 44 | $pluginData, |
| 45 | &$apiResponse |
| 46 | ], [ 'abortable' => true ] ); |
| 47 | } |
| 48 | |
| 49 | /** @inheritDoc */ |
| 50 | public function onVisualEditorApiVisualEditorEditPostSave( |
| 51 | ProperPageIdentity $page, |
| 52 | UserIdentity $user, |
| 53 | string $wikitext, |
| 54 | array $params, |
| 55 | array $pluginData, |
| 56 | array $saveResult, |
| 57 | array &$apiResponse |
| 58 | ): void { |
| 59 | $this->hookContainer->run( 'VisualEditorApiVisualEditorEditPostSave', [ |
| 60 | $page, |
| 61 | $user, |
| 62 | $wikitext, |
| 63 | $params, |
| 64 | $pluginData, |
| 65 | $saveResult, |
| 66 | &$apiResponse |
| 67 | ], [ 'abortable' => false ] ); |
| 68 | } |
| 69 | |
| 70 | /** @inheritDoc */ |
| 71 | public function onVisualEditorRegisterChangeTags( array &$tags ): void { |
| 72 | $this->hookContainer->run( 'VisualEditorRegisterChangeTags', [ |
| 73 | &$tags |
| 74 | ], [ 'abortable' => false ] ); |
| 75 | } |
| 76 | |
| 77 | /** @inheritDoc */ |
| 78 | public function onVisualEditorBeforeEditor( |
| 79 | OutputPage $output, |
| 80 | Skin $skin |
| 81 | ): bool { |
| 82 | return $this->hookContainer->run( 'VisualEditorBeforeEditor', [ |
| 83 | $output, |
| 84 | $skin |
| 85 | ], [ 'abortable' => true ] ); |
| 86 | } |
| 87 | } |