mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Nuke
synced 2024-12-02 20:06:27 +00:00
52d27a2714
Change-Id: If386a072e64f7c4903be911f5f70db3ee52338c2
68 lines
1.7 KiB
PHP
68 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Nuke\Hooks;
|
|
|
|
use MediaWiki\HookContainer\HookContainer;
|
|
use Title;
|
|
|
|
/**
|
|
* Handle running Nuke's hooks
|
|
* @author DannyS712
|
|
*/
|
|
class NukeHookRunner implements NukeDeletePageHook, NukeGetNewPagesHook {
|
|
|
|
/** @var HookContainer */
|
|
private $hookContainer;
|
|
|
|
/**
|
|
* @param HookContainer $hookContainer
|
|
*/
|
|
public function __construct( HookContainer $hookContainer ) {
|
|
$this->hookContainer = $hookContainer;
|
|
}
|
|
|
|
/**
|
|
* Hook runner for the `NukeDeletePage` hook
|
|
*
|
|
* Allows other extensions to handle the deletion of titles
|
|
* Return true to let Nuke handle the deletion or false if it was already handled in the hook.
|
|
*
|
|
* @param Title $title title to delete
|
|
* @param string $reason reason for deletion
|
|
* @param bool &$deletionResult Whether the deletion was successful or not
|
|
* @return bool|void
|
|
*/
|
|
public function onNukeDeletePage( Title $title, string $reason, bool &$deletionResult ) {
|
|
return $this->hookContainer->run(
|
|
'NukeDeletePage',
|
|
[ $title, $reason, &$deletionResult ]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Hook runner for the `NukeGetNewPages` hook
|
|
*
|
|
* After searching for pages to delete. Can be used to add and remove pages.
|
|
*
|
|
* @param string $username username filter applied
|
|
* @param ?string $pattern pattern filter applied
|
|
* @param ?int $namespace namespace filter applied
|
|
* @param int $limit limit filter applied
|
|
* @param array &$pages page titles already retrieved
|
|
* @return bool|void
|
|
*/
|
|
public function onNukeGetNewPages(
|
|
string $username,
|
|
?string $pattern,
|
|
?int $namespace,
|
|
int $limit,
|
|
array &$pages
|
|
) {
|
|
return $this->hookContainer->run(
|
|
'NukeGetNewPages',
|
|
[ $username, $pattern, $namespace, $limit, &$pages ]
|
|
);
|
|
}
|
|
|
|
}
|