2021-04-22 19:27:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\VisualEditor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* VisualEditorHookRunner
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @copyright 2011-2021 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
use MediaWiki\HookContainer\HookContainer;
|
|
|
|
use MediaWiki\Page\ProperPageIdentity;
|
|
|
|
use MediaWiki\User\UserIdentity;
|
2022-02-01 15:10:33 +00:00
|
|
|
use OutputPage;
|
|
|
|
use Skin;
|
2021-04-22 19:27:47 +00:00
|
|
|
|
2021-06-11 12:34:21 +00:00
|
|
|
class VisualEditorHookRunner implements
|
|
|
|
VisualEditorApiVisualEditorEditPreSaveHook,
|
2022-02-01 15:10:33 +00:00
|
|
|
VisualEditorApiVisualEditorEditPostSaveHook,
|
|
|
|
VisualEditorBeforeEditorHook
|
2021-06-11 12:34:21 +00:00
|
|
|
{
|
2021-04-22 19:27:47 +00:00
|
|
|
|
|
|
|
/** @var HookContainer */
|
|
|
|
private $hookContainer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param HookContainer $hookContainer
|
|
|
|
*/
|
|
|
|
public function __construct( HookContainer $hookContainer ) {
|
|
|
|
$this->hookContainer = $hookContainer;
|
|
|
|
}
|
|
|
|
|
2021-06-11 12:34:21 +00:00
|
|
|
/** @inheritDoc */
|
|
|
|
public function onVisualEditorApiVisualEditorEditPreSave(
|
|
|
|
ProperPageIdentity $page,
|
|
|
|
UserIdentity $user,
|
|
|
|
string $wikitext,
|
2022-03-27 20:41:20 +00:00
|
|
|
array &$params,
|
2021-06-11 12:34:21 +00:00
|
|
|
array $pluginData,
|
|
|
|
array &$apiResponse
|
|
|
|
) {
|
|
|
|
return $this->hookContainer->run( 'VisualEditorApiVisualEditorEditPreSave', [
|
|
|
|
$page,
|
|
|
|
$user,
|
|
|
|
$wikitext,
|
2022-03-27 20:41:20 +00:00
|
|
|
&$params,
|
2021-06-11 12:34:21 +00:00
|
|
|
$pluginData,
|
|
|
|
&$apiResponse
|
|
|
|
], [ 'abortable' => true ] );
|
|
|
|
}
|
|
|
|
|
2021-04-22 19:27:47 +00:00
|
|
|
/** @inheritDoc */
|
|
|
|
public function onVisualEditorApiVisualEditorEditPostSave(
|
|
|
|
ProperPageIdentity $page,
|
|
|
|
UserIdentity $user,
|
|
|
|
string $wikitext,
|
|
|
|
array $params,
|
|
|
|
array $pluginData,
|
|
|
|
array $saveResult,
|
|
|
|
array &$apiResponse
|
|
|
|
): void {
|
|
|
|
$this->hookContainer->run( 'VisualEditorApiVisualEditorEditPostSave', [
|
|
|
|
$page,
|
|
|
|
$user,
|
|
|
|
$wikitext,
|
|
|
|
$params,
|
|
|
|
$pluginData,
|
|
|
|
$saveResult,
|
|
|
|
&$apiResponse
|
|
|
|
], [ 'abortable' => false ] );
|
|
|
|
}
|
2022-02-01 15:10:33 +00:00
|
|
|
|
|
|
|
/** @inheritDoc */
|
2022-02-14 23:24:46 +00:00
|
|
|
public function onVisualEditorBeforeEditor(
|
2022-02-01 15:10:33 +00:00
|
|
|
OutputPage $output,
|
|
|
|
Skin $skin
|
|
|
|
): bool {
|
2022-02-14 23:24:46 +00:00
|
|
|
return $this->hookContainer->run( 'VisualEditorBeforeEditor', [
|
2022-02-01 15:10:33 +00:00
|
|
|
$output,
|
|
|
|
$skin
|
|
|
|
], [ 'abortable' => true ] );
|
|
|
|
}
|
2021-04-22 19:27:47 +00:00
|
|
|
}
|