Use MinervaNeue hook to disable talk overlay if DT mobile enabled

Bug: T280051
Change-Id: I6a52adcfd8030b26649b609ca99902ff840e8fdf
This commit is contained in:
David Lynch 2021-06-09 14:55:45 -05:00 committed by DLynch
parent 900a01772f
commit 7588a393e4
2 changed files with 34 additions and 0 deletions

View file

@ -425,6 +425,7 @@
"BeforeCreateEchoEvent": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks\\EchoHooks::onBeforeCreateEchoEvent",
"EchoGetBundleRules": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks\\EchoHooks::onEchoGetBundleRules",
"EchoGetEventsForRevision": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks\\EchoHooks::onEchoGetEventsForRevision",
"MinervaNeueTalkPageOverlay": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks\\MobileHooks::onMinervaNeueTalkPageOverlay",
"LoadExtensionSchemaUpdates": "installer",
"ParserAfterParse": "parser",
"ParserAfterTidy": "parser",

View file

@ -0,0 +1,33 @@
<?php
/**
* DiscussionTools mobile hooks
*
* @file
* @ingroup Extensions
* @license MIT
*/
namespace MediaWiki\Extension\DiscussionTools\Hooks;
use MediaWiki\MediaWikiServices;
class MobileHooks {
/**
* Decide whether mobile frontend should be allowed to activate
*
* @param \Title $title
* @param \OutputPage $output
* @return bool|void This hook can return false to abort, causing the talk overlay to not be shown
*/
public static function onMinervaNeueTalkPageOverlay( $title, $output ) {
$dtConfig = MediaWikiServices::getInstance()->getConfigFactory()
->makeConfig( 'discussiontools' );
if ( !$dtConfig->get( 'DiscussionToolsEnableMobile' ) ) {
return true;
}
if ( HookUtils::isFeatureEnabledForOutput( $output ) ) {
return false;
}
return true;
}
}