Hey Sigbert
In your extension.json have something like "callback": "Iframe::onRegistration",
You should also register your config variables in extension.json. For instance: "config": { "IFrameExternalJSONFile": false, "IFrameDifferentSetting": 42 },
The callback is executed during the setup process, after the LocalSettings has been processed in total. It is not called directly when wfLoadExtension('Iframe') is called. So you can add your setting after the wfLoadExtension('Iframe')-call: wfLoadExtesnion('Iframe'); $wgIFrameExternalJSONFile = __DIR__ . '/nice.json';
Inside the onRegistration() method, you can either use $GLOBALS or use the ConfigFactory to access the setting: $json = $GLOBALS['wgIFrameExternalJSONFile']
$configFactory = MediaWikiServices::getInstance()->getConfigFactory(); $configFactory->register( 'IFrame', 'GlobalVarConfig::newInstance' ); // this is necessary due to a bug in the extension registration process, see [0] $myConfig = $configFactory->makeConfig( 'Iframe' ); $json = $myConfig->get( 'IFrameExternalJSONFile' )
I know, the use of the config factory looks like a little bit of an overkill, however since mw wants to steer away from using globals, this is the safer way to go.
[0]: https://phabricator.wikimedia.org/T184837
Cheers, Tobias -- If this email is rather brief, it is not meant to be impolite but to respect your time. http://five.sentenc.es No trees were killed to send this message, but a large number of electrons were terribly inconvenienced
-----Ursprüngliche Nachricht----- Von: MediaWiki-l [mailto:mediawiki-l-bounces@lists.wikimedia.org] Im Auftrag von Sigbert Klinke Gesendet: Dienstag, 13. Februar 2018 10:22 An: MediaWiki announcements and site admin list <mediawiki- l@lists.wikimedia.org> Betreff: [MediaWiki-l] extension.json, onRegistration
Hi,
for my Iframe extension I need to load some data. Since the data come from a file I did not put it into extension.json, but I defined in my class a function onRegistration with sets a global variable.
However, it turned out that in LocalSettings.php I can not set the global variable (after calling wfLoadExtesnion('Iframe') ), var_dump delivers NULL rather than my file data.
Question: where I have to put the reading of my file data (if not into onRegistration) ?
Thanks Sigbert
-- https://hu.berlin/sk https://hu.berlin/mmstat3
MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l