mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 14:06:52 +00:00
Allow hook implementations to modify params
This is needed because the $params array is then passed on to ApiEditPage, so if the hook implementer wants to alter the data used with the edit, it needs to be able to modify the $params. See I494d72a42d9103c28c4d44077cfe0f1269fc7b00 for an example where GrowthExperiments would like to modify the 'tags' parameter for an edit. Depends-On: Idd052281898f99e4f13f241d5633294b59b29329 Bug: T304747 Change-Id: Ia4842a1593028f5fa145de167ccf9b72efa81351
This commit is contained in:
parent
09a378d515
commit
9241add01e
|
@ -24,8 +24,9 @@ interface VisualEditorApiVisualEditorEditPreSaveHook {
|
|||
* @param ProperPageIdentity $page The page identity of the title used in the save attempt.
|
||||
* @param UserIdentity $user User associated with the save attempt.
|
||||
* @param string $wikitext The wikitext used in the save attempt.
|
||||
* @param array $params The params passed by the client in the API request. See
|
||||
* ApiVisualEditorEdit::getAllowedParams()
|
||||
* @param array &$params The params passed by the client in the API request. See
|
||||
* ApiVisualEditorEdit::getAllowedParams(). Note that these params are then passed on to ApiEditPage, so
|
||||
* the array is modifiable in case the hook implementer needs to adjust any of the parameters.
|
||||
* @param array $pluginData Associative array containing additional data specified by plugins, where the keys of
|
||||
* the array are plugin names, and the value are arbitrary data. Plugins are expected to be in a one-to-one
|
||||
* correlation with hook handlers and can be specified via the 'plugins' and 'data-*' parameters of the API.
|
||||
|
@ -44,7 +45,7 @@ interface VisualEditorApiVisualEditorEditPreSaveHook {
|
|||
ProperPageIdentity $page,
|
||||
UserIdentity $user,
|
||||
string $wikitext,
|
||||
array $params,
|
||||
array &$params,
|
||||
array $pluginData,
|
||||
array &$apiResponse
|
||||
);
|
||||
|
|
|
@ -40,7 +40,7 @@ class VisualEditorHookRunner implements
|
|||
ProperPageIdentity $page,
|
||||
UserIdentity $user,
|
||||
string $wikitext,
|
||||
array $params,
|
||||
array &$params,
|
||||
array $pluginData,
|
||||
array &$apiResponse
|
||||
) {
|
||||
|
@ -48,7 +48,7 @@ class VisualEditorHookRunner implements
|
|||
$page,
|
||||
$user,
|
||||
$wikitext,
|
||||
$params,
|
||||
&$params,
|
||||
$pluginData,
|
||||
&$apiResponse
|
||||
], [ 'abortable' => true ] );
|
||||
|
|
|
@ -26,11 +26,12 @@ class VisualEditorHookRunnerTest extends MediaWikiUnitTestCase {
|
|||
$runner = new VisualEditorHookRunner( $container );
|
||||
|
||||
$apiResponse = [];
|
||||
$params = [];
|
||||
$result = $runner->onVisualEditorApiVisualEditorEditPreSave(
|
||||
PageIdentityValue::localIdentity( 0, 0, 'test' ),
|
||||
UserIdentityValue::newAnonymous( '' ),
|
||||
'',
|
||||
[],
|
||||
$params,
|
||||
[],
|
||||
$apiResponse
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue