Manual talk:Hooks/ResourceLoaderGetConfigVars

About this board

Remove global variables from the example

1
Gabriel Birke (WMDE) (talkcontribs)

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.

Reply to "Remove global variables from the example"
There are no older topics
Return to "Hooks/ResourceLoaderGetConfigVars" page.