Migrate change tags hooks to DI

Bug: T261067
Change-Id: I7b95cd19ab0ae04820e8dcb3481d29a2f9e7a0ca
This commit is contained in:
Matěj Suchánek 2020-10-14 16:32:55 +02:00 committed by Daimona Eaytoy
parent 85e000c6ed
commit 2ee3a0d247
3 changed files with 49 additions and 26 deletions

View file

@ -277,6 +277,10 @@
"ToolLinks": {
"class": "MediaWiki\\Extension\\AbuseFilter\\Hooks\\Handlers\\ToolLinksHandler",
"services": [ "AbuseFilterPermissionManager" ]
},
"ChangeTags": {
"class": "MediaWiki\\Extension\\AbuseFilter\\Hooks\\Handlers\\ChangeTagsHandler",
"services": [ "AbuseFilterChangeTagsManager" ]
}
},
"Hooks": {
@ -285,8 +289,8 @@
"TitleMove": "AbuseFilterHooks::onTitleMove",
"ArticleDelete": "AbuseFilterHooks::onArticleDelete",
"RecentChange_save": "AbuseFilterHooks::onRecentChangeSave",
"ListDefinedTags": "AbuseFilterHooks::onListDefinedTags",
"ChangeTagsListActive": "AbuseFilterHooks::onChangeTagsListActive",
"ListDefinedTags": "ChangeTags",
"ChangeTagsListActive": "ChangeTags",
"LoadExtensionSchemaUpdates": "AbuseFilterHooks::onLoadExtensionSchemaUpdates",
"ContributionsToolLinks": "ToolLinks",
"HistoryPageToolLinks": "ToolLinks",

View file

@ -335,30 +335,6 @@ class AbuseFilterHooks {
}
}
/**
* @param string[] &$tags
*/
public static function onListDefinedTags( array &$tags ) {
$manager = AbuseFilterServices::getChangeTagsManager();
$tags = array_merge(
$tags,
$manager->getTagsDefinedByFilters(),
[ $manager->getCondsLimitTag() ]
);
}
/**
* @param string[] &$tags
*/
public static function onChangeTagsListActive( array &$tags ) {
$manager = AbuseFilterServices::getChangeTagsManager();
$tags = array_merge(
$tags,
$manager->getTagsDefinedByActiveFilters(),
[ $manager->getCondsLimitTag() ]
);
}
/**
* @param DatabaseUpdater $updater
* @throws MWException

View file

@ -0,0 +1,43 @@
<?php
namespace MediaWiki\Extension\AbuseFilter\Hooks\Handlers;
use MediaWiki\Extension\AbuseFilter\ChangeTagsManager;
class ChangeTagsHandler implements
\MediaWiki\ChangeTags\Hook\ListDefinedTagsHook,
\MediaWiki\ChangeTags\Hook\ChangeTagsListActiveHook
{
/** @var ChangeTagsManager */
private $changeTagsManager;
/**
* @param ChangeTagsManager $changeTagsManager
*/
public function __construct( ChangeTagsManager $changeTagsManager ) {
$this->changeTagsManager = $changeTagsManager;
}
/**
* @param string[] &$tags
*/
public function onListDefinedTags( &$tags ) {
$tags = array_merge(
$tags,
$this->changeTagsManager->getTagsDefinedByFilters(),
[ $this->changeTagsManager->getCondsLimitTag() ]
);
}
/**
* @param string[] &$tags
*/
public function onChangeTagsListActive( &$tags ) {
$tags = array_merge(
$tags,
$this->changeTagsManager->getTagsDefinedByActiveFilters(),
[ $this->changeTagsManager->getCondsLimitTag() ]
);
}
}