mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
1d449787ef
Most of this code was already typed, but not everything. Using language-level type declarations allows us to remove extra PHPDoc blocks that just repeat the same information. I'm also using the more narrow UserIdentity instead of User in a few places where this is possible. Change-Id: I7661824fcb34180af1a4fd3030fcd6c0b7d34089
83 lines
1.7 KiB
PHP
83 lines
1.7 KiB
PHP
<?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;
|
|
use OutputPage;
|
|
use Skin;
|
|
|
|
class VisualEditorHookRunner implements
|
|
VisualEditorApiVisualEditorEditPreSaveHook,
|
|
VisualEditorApiVisualEditorEditPostSaveHook,
|
|
VisualEditorBeforeEditorHook
|
|
{
|
|
|
|
private HookContainer $hookContainer;
|
|
|
|
public function __construct( HookContainer $hookContainer ) {
|
|
$this->hookContainer = $hookContainer;
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
public function onVisualEditorApiVisualEditorEditPreSave(
|
|
ProperPageIdentity $page,
|
|
UserIdentity $user,
|
|
string $wikitext,
|
|
array &$params,
|
|
array $pluginData,
|
|
array &$apiResponse
|
|
) {
|
|
return $this->hookContainer->run( 'VisualEditorApiVisualEditorEditPreSave', [
|
|
$page,
|
|
$user,
|
|
$wikitext,
|
|
&$params,
|
|
$pluginData,
|
|
&$apiResponse
|
|
], [ 'abortable' => true ] );
|
|
}
|
|
|
|
/** @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 ] );
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
public function onVisualEditorBeforeEditor(
|
|
OutputPage $output,
|
|
Skin $skin
|
|
): bool {
|
|
return $this->hookContainer->run( 'VisualEditorBeforeEditor', [
|
|
$output,
|
|
$skin
|
|
], [ 'abortable' => true ] );
|
|
}
|
|
}
|