Inject service SpecialPageFactory

Change-Id: Ia38b468741bdfd5bab5bb34df79bf01d549498a9
This commit is contained in:
Fomafix 2022-11-05 09:25:26 +00:00
parent 4874172242
commit 56d8a8df55
3 changed files with 14 additions and 3 deletions

View file

@ -24,6 +24,7 @@ use Config;
use ExtensionRegistry;
use MediaWiki\Extension\BetaFeatures\BetaFeatures;
use MediaWiki\MediaWikiServices;
use MediaWiki\SpecialPage\SpecialPageFactory;
use MediaWiki\User\UserOptionsLookup;
use Title;
@ -95,6 +96,11 @@ class PopupsContext {
*/
private $gadgetsIntegration;
/**
* @var SpecialPageFactory
*/
private $specialPageFactory;
/**
* @var UserOptionsLookup
*/
@ -104,6 +110,7 @@ class PopupsContext {
* @param Config $config Mediawiki configuration
* @param ExtensionRegistry $extensionRegistry MediaWiki extension registry
* @param PopupsGadgetsIntegration $gadgetsIntegration Gadgets integration helper
* @param SpecialPageFactory $specialPageFactory
* @param UserOptionsLookup $userOptionsLookup
* events
*/
@ -111,10 +118,12 @@ class PopupsContext {
Config $config,
ExtensionRegistry $extensionRegistry,
PopupsGadgetsIntegration $gadgetsIntegration,
SpecialPageFactory $specialPageFactory,
UserOptionsLookup $userOptionsLookup
) {
$this->extensionRegistry = $extensionRegistry;
$this->gadgetsIntegration = $gadgetsIntegration;
$this->specialPageFactory = $specialPageFactory;
$this->userOptionsLookup = $userOptionsLookup;
$this->config = $config;
@ -241,7 +250,7 @@ class PopupsContext {
if ( $title->isSpecialPage() ) {
// it's special page, translate it to canonical name
[ $name, $subpage ] = MediaWikiServices::getInstance()->getSpecialPageFactory()
[ $name, $subpage ] = $this->specialPageFactory
->resolveAlias( $canonicalTitle->getText() );
if ( $name !== null ) {

View file

@ -27,6 +27,7 @@ return [
$services->getService( 'Popups.Config' ),
ExtensionRegistry::getInstance(),
$services->getService( 'Popups.GadgetsIntegration' ),
$services->getSpecialPageFactory(),
$services->getUserOptionsLookup()
);
}

View file

@ -50,12 +50,13 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
$integration->method( 'conflictsWithNavPopupsGadget' )
->willReturn( false );
}
$userOptionsLookup = MediaWikiServices::getInstance()->getUserOptionsLookup();
$services = MediaWikiServices::getInstance();
return new PopupsContext(
$config,
$registry,
$integration,
$userOptionsLookup
$services->getSpecialPageFactory(),
$services->getUserOptionsLookup()
);
}