Jump to content

Manual talk:Hooks/ResourceLoaderGetConfigVars

Add topic
From mediawiki.org
Latest comment: 7 years ago by Gabriel Birke (WMDE) in topic Remove global variables from the example

Remove global variables from the example

[edit]

The same result as in the example, but without using the global keyword:

class VisualEditorHooks {
    public static function onResourceLoaderGetConfigVars( array &$vars ) {
      $config = MediaWikiServices::getInstance()->getMainConfig();
      $vars['wgVisualEditor'] = [
       'disableForAnons' => $config->get( 'VisualEditorDisableForAnons' ),
       'enableExperimentalCode' => $config->get( 'VisualEditorEnableExperimentalCode '),
      ];
      return true;
    }
  }

This would get rid of the global variables, which might be deprecated in the future. Gabriel Birke (WMDE) (talk) 16:41, 28 February 2018 (UTC)Reply