mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-23 15:57:15 +00:00
Use "optional_services" to inject service MobileContext
This change requires a soft dependency on extension MobileFrontend in project integration/config in file zuul/parameter_functions.py. Depends-On: Idd55fb06cb166c00817f53287ab17984cae6a7a4 Change-Id: Ia0f6dc59cfac3d201c19bc4a62a5df9590c1ed37
This commit is contained in:
parent
37e032fb8c
commit
9b7ec7ec48
|
@ -6,6 +6,7 @@ $cfg['directory_list'] = array_merge(
|
||||||
$cfg['directory_list'],
|
$cfg['directory_list'],
|
||||||
[
|
[
|
||||||
'../../extensions/EventLogging',
|
'../../extensions/EventLogging',
|
||||||
|
'../../extensions/MobileFrontend',
|
||||||
'../../extensions/WikimediaEvents',
|
'../../extensions/WikimediaEvents',
|
||||||
'../../extensions/ConfirmEdit',
|
'../../extensions/ConfirmEdit',
|
||||||
]
|
]
|
||||||
|
@ -15,6 +16,7 @@ $cfg['exclude_analysis_directory_list'] = array_merge(
|
||||||
$cfg['exclude_analysis_directory_list'],
|
$cfg['exclude_analysis_directory_list'],
|
||||||
[
|
[
|
||||||
'../../extensions/EventLogging',
|
'../../extensions/EventLogging',
|
||||||
|
'../../extensions/MobileFrontend',
|
||||||
'../../extensions/WikimediaEvents',
|
'../../extensions/WikimediaEvents',
|
||||||
'../../extensions/ConfirmEdit',
|
'../../extensions/ConfirmEdit',
|
||||||
]
|
]
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
"MainConfig",
|
"MainConfig",
|
||||||
"UserEditTracker",
|
"UserEditTracker",
|
||||||
"UserOptionsLookup"
|
"UserOptionsLookup"
|
||||||
|
],
|
||||||
|
"optional_services": [
|
||||||
|
"MobileFrontend.Context"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -38,6 +38,7 @@ use MediaWiki\User\User;
|
||||||
use MediaWiki\User\UserEditTracker;
|
use MediaWiki\User\UserEditTracker;
|
||||||
use MediaWiki\WikiMap\WikiMap;
|
use MediaWiki\WikiMap\WikiMap;
|
||||||
use MessageLocalizer;
|
use MessageLocalizer;
|
||||||
|
use MobileContext;
|
||||||
use MWCryptRand;
|
use MWCryptRand;
|
||||||
use RecentChange;
|
use RecentChange;
|
||||||
use RequestContext;
|
use RequestContext;
|
||||||
|
@ -73,19 +74,25 @@ class Hooks implements
|
||||||
/** @var UserOptionsLookup */
|
/** @var UserOptionsLookup */
|
||||||
private $userOptionsLookup;
|
private $userOptionsLookup;
|
||||||
|
|
||||||
|
/** @var MobileContext|null */
|
||||||
|
private ?MobileContext $mobileContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Config $config
|
* @param Config $config
|
||||||
* @param UserEditTracker $userEditTracker
|
* @param UserEditTracker $userEditTracker
|
||||||
* @param UserOptionsLookup $userOptionsLookup
|
* @param UserOptionsLookup $userOptionsLookup
|
||||||
|
* @param MobileContext|null $mobileContext
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Config $config,
|
Config $config,
|
||||||
UserEditTracker $userEditTracker,
|
UserEditTracker $userEditTracker,
|
||||||
UserOptionsLookup $userOptionsLookup
|
UserOptionsLookup $userOptionsLookup,
|
||||||
|
?MobileContext $mobileContext
|
||||||
) {
|
) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->userEditTracker = $userEditTracker;
|
$this->userEditTracker = $userEditTracker;
|
||||||
$this->userOptionsLookup = $userOptionsLookup;
|
$this->userOptionsLookup = $userOptionsLookup;
|
||||||
|
$this->mobileContext = $mobileContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,9 +137,8 @@ class Hooks implements
|
||||||
if ( !$extensionRegistry->isLoaded( 'EventLogging' ) || !$extensionRegistry->isLoaded( 'WikimediaEvents' ) ) {
|
if ( !$extensionRegistry->isLoaded( 'EventLogging' ) || !$extensionRegistry->isLoaded( 'WikimediaEvents' ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( $extensionRegistry->isLoaded( 'MobileFrontend' ) ) {
|
if ( $extensionRegistry->isLoaded( 'MobileFrontend' ) && $this->mobileContext ) {
|
||||||
$mobFrontContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
|
if ( $this->mobileContext->shouldDisplayMobileView() ) {
|
||||||
if ( $mobFrontContext->shouldDisplayMobileView() ) {
|
|
||||||
// on a MobileFrontend page the logging should be handled by it
|
// on a MobileFrontend page the logging should be handled by it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue