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