Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\VisualEditor; |
4 | |
5 | use MediaWiki\Page\ProperPageIdentity; |
6 | use MediaWiki\User\UserIdentity; |
7 | |
8 | /** |
9 | * VisualEditorApiVisualEditorEditPreSaveHook |
10 | * |
11 | * @file |
12 | * @ingroup Extensions |
13 | * @copyright 2011-2021 VisualEditor Team and others; see AUTHORS.txt |
14 | * @license MIT |
15 | */ |
16 | |
17 | interface VisualEditorApiVisualEditorEditPreSaveHook { |
18 | |
19 | /** |
20 | * This hook is executed in calls to ApiVisualEditorEdit using action=save, before the save is attempted. |
21 | * |
22 | * This hook can abort the save attempt by returning false. |
23 | * |
24 | * @param ProperPageIdentity $page The page identity of the title used in the save attempt. |
25 | * @param UserIdentity $user User associated with the save attempt. |
26 | * @param string $wikitext The wikitext used in the save attempt. |
27 | * @param array &$params The params passed by the client in the API request. See |
28 | * ApiVisualEditorEdit::getAllowedParams(). Note that these params are then passed on to ApiEditPage, so |
29 | * the array is modifiable in case the hook implementer needs to adjust any of the parameters. |
30 | * @param array $pluginData Associative array containing additional data specified by plugins, where the keys of |
31 | * the array are plugin names, and the value are arbitrary data. Plugins are expected to be in a one-to-one |
32 | * correlation with hook handlers and can be specified via the 'plugins' and 'data-*' parameters of the API. |
33 | * @param array &$apiResponse The modifiable API response that VisualEditor will return to the client. |
34 | * There are several keys that are used by VisualEditor and will be overwritten if set here, notable ones include |
35 | * "result" and "edit". See ApiVisualEditorEdit::execute(). |
36 | * Note: When returning false, the "message" key must be set to a valid i18n message key, e.g. |
37 | * ```php |
38 | * $apiResponse['message'] = [ 'growthexperiments-addlink-notinstore', $title->getPrefixedText() ]; |
39 | * return false; |
40 | * @return void|bool |
41 | * False will abort the save attempt and return an error to the client. If false is returned, the implementer |
42 | * must also set the "message" key in $apiResponse for rendering the error response to the client. |
43 | */ |
44 | public function onVisualEditorApiVisualEditorEditPreSave( |
45 | ProperPageIdentity $page, |
46 | UserIdentity $user, |
47 | string $wikitext, |
48 | array &$params, |
49 | array $pluginData, |
50 | array &$apiResponse |
51 | ); |
52 | |
53 | } |