mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ReplaceText
synced 2024-11-27 07:59:59 +00:00
Use HookHandlers for AdminLinks hooks
Bug: T271025 Change-Id: Ie4fac4a457eecd64bd5f66628f86cbee9ab9c84f
This commit is contained in:
parent
2f7bfbed73
commit
203564d43d
5
.phan/stubs/AdminLinksHook.php
Normal file
5
.phan/stubs/AdminLinksHook.php
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
interface AdminLinksHook {
|
||||||
|
public function onAdminLinks( ALTree &$admin_links_tree );
|
||||||
|
}
|
|
@ -70,9 +70,7 @@
|
||||||
"MediaWiki\\Extension\\ReplaceText\\": "src/"
|
"MediaWiki\\Extension\\ReplaceText\\": "src/"
|
||||||
},
|
},
|
||||||
"Hooks": {
|
"Hooks": {
|
||||||
"AdminLinks": [
|
"AdminLinks": "adminlinks",
|
||||||
"MediaWiki\\Extension\\ReplaceText\\Hooks::addToAdminLinks"
|
|
||||||
],
|
|
||||||
"SpecialMovepageAfterMove": "main",
|
"SpecialMovepageAfterMove": "main",
|
||||||
"UserGetReservedNames": "main"
|
"UserGetReservedNames": "main"
|
||||||
},
|
},
|
||||||
|
@ -83,6 +81,9 @@
|
||||||
"MainConfig",
|
"MainConfig",
|
||||||
"SpecialPageFactory"
|
"SpecialPageFactory"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"adminlinks": {
|
||||||
|
"class": "MediaWiki\\Extension\\ReplaceText\\AdminLinksHooks"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|
32
src/AdminLinksHooks.php
Normal file
32
src/AdminLinksHooks.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MediaWiki\Extension\ReplaceText;
|
||||||
|
|
||||||
|
use AdminLinksHook;
|
||||||
|
use ALItem;
|
||||||
|
use ALRow;
|
||||||
|
use ALTree;
|
||||||
|
|
||||||
|
class AdminLinksHooks implements AdminLinksHook {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements AdminLinks hook from Extension:Admin_Links.
|
||||||
|
*
|
||||||
|
* @param ALTree &$adminLinksTree
|
||||||
|
*/
|
||||||
|
public function onAdminLinks( ALTree &$adminLinksTree ) {
|
||||||
|
$generalSection = $adminLinksTree->getSection( wfMessage( 'adminlinks_general' )->text() );
|
||||||
|
|
||||||
|
if ( !$generalSection ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$extensionsRow = $generalSection->getRow( 'extensions' );
|
||||||
|
|
||||||
|
if ( $extensionsRow === null ) {
|
||||||
|
$extensionsRow = new ALRow( 'extensions' );
|
||||||
|
$generalSection->addRow( $extensionsRow );
|
||||||
|
}
|
||||||
|
|
||||||
|
$extensionsRow->addItem( ALItem::newFromSpecialPage( 'ReplaceText' ) );
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,9 +21,6 @@
|
||||||
*/
|
*/
|
||||||
namespace MediaWiki\Extension\ReplaceText;
|
namespace MediaWiki\Extension\ReplaceText;
|
||||||
|
|
||||||
use ALItem;
|
|
||||||
use ALRow;
|
|
||||||
use ALTree;
|
|
||||||
use Config;
|
use Config;
|
||||||
use MediaWiki\Hook\SpecialMovepageAfterMoveHook;
|
use MediaWiki\Hook\SpecialMovepageAfterMoveHook;
|
||||||
use MediaWiki\SpecialPage\SpecialPageFactory;
|
use MediaWiki\SpecialPage\SpecialPageFactory;
|
||||||
|
@ -54,30 +51,6 @@ class Hooks implements
|
||||||
$this->specialPageFactory = $specialPageFactory;
|
$this->specialPageFactory = $specialPageFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements AdminLinks hook from Extension:Admin_Links.
|
|
||||||
*
|
|
||||||
* @param ALTree &$adminLinksTree
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function addToAdminLinks( ALTree &$adminLinksTree ) {
|
|
||||||
$generalSection = $adminLinksTree->getSection( wfMessage( 'adminlinks_general' )->text() );
|
|
||||||
|
|
||||||
if ( !$generalSection ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$extensionsRow = $generalSection->getRow( 'extensions' );
|
|
||||||
|
|
||||||
if ( $extensionsRow === null ) {
|
|
||||||
$extensionsRow = new ALRow( 'extensions' );
|
|
||||||
$generalSection->addRow( $extensionsRow );
|
|
||||||
}
|
|
||||||
|
|
||||||
$extensionsRow->addItem( ALItem::newFromSpecialPage( 'ReplaceText' ) );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements SpecialMovepageAfterMove hook.
|
* Implements SpecialMovepageAfterMove hook.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue