mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ReplaceText
synced 2024-11-23 14:26:47 +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/"
|
||||
},
|
||||
"Hooks": {
|
||||
"AdminLinks": [
|
||||
"MediaWiki\\Extension\\ReplaceText\\Hooks::addToAdminLinks"
|
||||
],
|
||||
"AdminLinks": "adminlinks",
|
||||
"SpecialMovepageAfterMove": "main",
|
||||
"UserGetReservedNames": "main"
|
||||
},
|
||||
|
@ -83,6 +81,9 @@
|
|||
"MainConfig",
|
||||
"SpecialPageFactory"
|
||||
]
|
||||
},
|
||||
"adminlinks": {
|
||||
"class": "MediaWiki\\Extension\\ReplaceText\\AdminLinksHooks"
|
||||
}
|
||||
},
|
||||
"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;
|
||||
|
||||
use ALItem;
|
||||
use ALRow;
|
||||
use ALTree;
|
||||
use Config;
|
||||
use MediaWiki\Hook\SpecialMovepageAfterMoveHook;
|
||||
use MediaWiki\SpecialPage\SpecialPageFactory;
|
||||
|
@ -54,30 +51,6 @@ class Hooks implements
|
|||
$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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue