Last active
March 12, 2021 13:24
-
-
Save atdt/4652474 to your computer and use it in GitHub Desktop.
Loading EventLogging modules conditionally.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// MyExtension.php | |
$wgHooks[ 'ResourceLoaderRegisterModules' ][] = function ( ResourceLoader &$resourceLoader ) { | |
/** @var array: list of modules that ext.myExtension.core depends on. **/ | |
$moduleDependencies = array( /* ... */ ); | |
// If EventLogging is present, declare the schema module | |
// and add it to the array of dependencies. | |
if ( class_exists( 'ResourceLoaderSchemaModule' ) ) ) { | |
$resourceLoader->register( "schema.MyExtension", array( | |
'class' => 'ResourceLoaderSchemaModule', | |
'schema' => 'MyExtension', | |
'revision' => 4948295 | |
); | |
$moduleDependencies[] = "schema.MyExtension"; | |
} | |
$resourceLoader->register( "ext.myExtension.core", array( | |
'scripts' => 'modules/ext.myExtension.js', | |
'dependencies' => $moduleDependencies, | |
'localBasePath' => __DIR__, | |
'remoteExtPath' => 'MyExtension' | |
) ); | |
return true; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var logEvent = mw.eventLog ? mw.eventLog.logEvent : function () {}; |
Eep. Fixed.
I think there still is an extra )
on L11. There needs to be ,
at the end of L15/25 and another )
on L16.
This should be updated to use the EventLoggingRegisterSchemas hook and maybe moved to a wiki somewhere?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You are missing [] form line 4. On line 11 there is extra ), On line 26 missing ) and after that missing "return true".