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'],
|
||||
[
|
||||
'../../extensions/EventLogging',
|
||||
'../../extensions/MobileFrontend',
|
||||
'../../extensions/WikimediaEvents',
|
||||
'../../extensions/ConfirmEdit',
|
||||
]
|
||||
|
@ -15,6 +16,7 @@ $cfg['exclude_analysis_directory_list'] = array_merge(
|
|||
$cfg['exclude_analysis_directory_list'],
|
||||
[
|
||||
'../../extensions/EventLogging',
|
||||
'../../extensions/MobileFrontend',
|
||||
'../../extensions/WikimediaEvents',
|
||||
'../../extensions/ConfirmEdit',
|
||||
]
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
"MainConfig",
|
||||
"UserEditTracker",
|
||||
"UserOptionsLookup"
|
||||
],
|
||||
"optional_services": [
|
||||
"MobileFrontend.Context"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -38,6 +38,7 @@ use MediaWiki\User\User;
|
|||
use MediaWiki\User\UserEditTracker;
|
||||
use MediaWiki\WikiMap\WikiMap;
|
||||
use MessageLocalizer;
|
||||
use MobileContext;
|
||||
use MWCryptRand;
|
||||
use RecentChange;
|
||||
use RequestContext;
|
||||
|
@ -73,19 +74,25 @@ class Hooks implements
|
|||
/** @var UserOptionsLookup */
|
||||
private $userOptionsLookup;
|
||||
|
||||
/** @var MobileContext|null */
|
||||
private ?MobileContext $mobileContext;
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
* @param UserEditTracker $userEditTracker
|
||||
* @param UserOptionsLookup $userOptionsLookup
|
||||
* @param MobileContext|null $mobileContext
|
||||
*/
|
||||
public function __construct(
|
||||
Config $config,
|
||||
UserEditTracker $userEditTracker,
|
||||
UserOptionsLookup $userOptionsLookup
|
||||
UserOptionsLookup $userOptionsLookup,
|
||||
?MobileContext $mobileContext
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->userEditTracker = $userEditTracker;
|
||||
$this->userOptionsLookup = $userOptionsLookup;
|
||||
$this->mobileContext = $mobileContext;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,9 +137,8 @@ class Hooks implements
|
|||
if ( !$extensionRegistry->isLoaded( 'EventLogging' ) || !$extensionRegistry->isLoaded( 'WikimediaEvents' ) ) {
|
||||
return;
|
||||
}
|
||||
if ( $extensionRegistry->isLoaded( 'MobileFrontend' ) ) {
|
||||
$mobFrontContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
|
||||
if ( $mobFrontContext->shouldDisplayMobileView() ) {
|
||||
if ( $extensionRegistry->isLoaded( 'MobileFrontend' ) && $this->mobileContext ) {
|
||||
if ( $this->mobileContext->shouldDisplayMobileView() ) {
|
||||
// on a MobileFrontend page the logging should be handled by it
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue