mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Merge "Allow hook implementations to modify params"
This commit is contained in:
commit
4bd4410b7b
|
@ -24,8 +24,9 @@ interface VisualEditorApiVisualEditorEditPreSaveHook {
|
||||||
* @param ProperPageIdentity $page The page identity of the title used in the save attempt.
|
* @param ProperPageIdentity $page The page identity of the title used in the save attempt.
|
||||||
* @param UserIdentity $user User associated with the save attempt.
|
* @param UserIdentity $user User associated with the save attempt.
|
||||||
* @param string $wikitext The wikitext used in 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
|
* @param array &$params The params passed by the client in the API request. See
|
||||||
* ApiVisualEditorEdit::getAllowedParams()
|
* 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
|
* @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
|
* 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.
|
* 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,
|
ProperPageIdentity $page,
|
||||||
UserIdentity $user,
|
UserIdentity $user,
|
||||||
string $wikitext,
|
string $wikitext,
|
||||||
array $params,
|
array &$params,
|
||||||
array $pluginData,
|
array $pluginData,
|
||||||
array &$apiResponse
|
array &$apiResponse
|
||||||
);
|
);
|
||||||
|
|
|
@ -40,7 +40,7 @@ class VisualEditorHookRunner implements
|
||||||
ProperPageIdentity $page,
|
ProperPageIdentity $page,
|
||||||
UserIdentity $user,
|
UserIdentity $user,
|
||||||
string $wikitext,
|
string $wikitext,
|
||||||
array $params,
|
array &$params,
|
||||||
array $pluginData,
|
array $pluginData,
|
||||||
array &$apiResponse
|
array &$apiResponse
|
||||||
) {
|
) {
|
||||||
|
@ -48,7 +48,7 @@ class VisualEditorHookRunner implements
|
||||||
$page,
|
$page,
|
||||||
$user,
|
$user,
|
||||||
$wikitext,
|
$wikitext,
|
||||||
$params,
|
&$params,
|
||||||
$pluginData,
|
$pluginData,
|
||||||
&$apiResponse
|
&$apiResponse
|
||||||
], [ 'abortable' => true ] );
|
], [ 'abortable' => true ] );
|
||||||
|
|
|
@ -26,11 +26,12 @@ class VisualEditorHookRunnerTest extends MediaWikiUnitTestCase {
|
||||||
$runner = new VisualEditorHookRunner( $container );
|
$runner = new VisualEditorHookRunner( $container );
|
||||||
|
|
||||||
$apiResponse = [];
|
$apiResponse = [];
|
||||||
|
$params = [];
|
||||||
$result = $runner->onVisualEditorApiVisualEditorEditPreSave(
|
$result = $runner->onVisualEditorApiVisualEditorEditPreSave(
|
||||||
PageIdentityValue::localIdentity( 0, 0, 'test' ),
|
PageIdentityValue::localIdentity( 0, 0, 'test' ),
|
||||||
UserIdentityValue::newAnonymous( '' ),
|
UserIdentityValue::newAnonymous( '' ),
|
||||||
'',
|
'',
|
||||||
[],
|
$params,
|
||||||
[],
|
[],
|
||||||
$apiResponse
|
$apiResponse
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue