mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeEditor
synced 2024-11-23 23:03:46 +00:00
Avoid using User::getOption and inject service UserOptionsLookup
Remove using of User:getOption since this method will be hard-deprecated. Now it is soft-deprecated Bug: T296083 Change-Id: Iae0c0cd3ab4ffdfd6cfce5e7ced81dfae3d4a359
This commit is contained in:
parent
ad1930d255
commit
51cd95fac9
|
@ -22,7 +22,10 @@
|
|||
},
|
||||
"HookHandlers": {
|
||||
"CodeEditorHooks": {
|
||||
"class": "MediaWiki\\Extension\\CodeEditor\\Hooks"
|
||||
"class": "MediaWiki\\Extension\\CodeEditor\\Hooks",
|
||||
"services": [
|
||||
"UserOptionsLookup"
|
||||
]
|
||||
}
|
||||
},
|
||||
"MessagesDirs": {
|
||||
|
|
|
@ -8,6 +8,7 @@ use ExtensionRegistry;
|
|||
use MediaWiki\Hook\EditPage__showEditForm_initialHook;
|
||||
use MediaWiki\Hook\EditPage__showReadOnlyForm_initialHook;
|
||||
use MediaWiki\Preferences\Hook\GetPreferencesHook;
|
||||
use MediaWiki\User\UserOptionsLookup;
|
||||
use OutputPage;
|
||||
use Title;
|
||||
use User;
|
||||
|
@ -20,6 +21,18 @@ class Hooks implements
|
|||
EditPage__showEditForm_initialHook,
|
||||
EditPage__showReadOnlyForm_initialHook
|
||||
{
|
||||
/** @var UserOptionsLookup */
|
||||
private $userOptionsLookup;
|
||||
|
||||
/**
|
||||
* @param UserOptionsLookup $userOptionsLookup
|
||||
*/
|
||||
public function __construct(
|
||||
UserOptionsLookup $userOptionsLookup
|
||||
) {
|
||||
$this->userOptionsLookup = $userOptionsLookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Title $title
|
||||
* @param string $model
|
||||
|
@ -65,7 +78,7 @@ class Hooks implements
|
|||
$format = $editpage->contentFormat;
|
||||
|
||||
$lang = self::getPageLanguage( $title, $model, $format );
|
||||
if ( $lang && $output->getUser()->getOption( 'usebetatoolbar' ) ) {
|
||||
if ( $lang && $this->userOptionsLookup->getOption( $output->getUser(), 'usebetatoolbar' ) ) {
|
||||
$output->addModules( 'ext.codeEditor' );
|
||||
$output->addJsConfigVars( 'wgCodeEditorCurrentLanguage', $lang );
|
||||
// Needed because ACE adds a blob: url web-worker.
|
||||
|
|
Loading…
Reference in a new issue