Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Loading EventLogging modules conditionally.
<?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;
};
var logEvent = mw.eventLog ? mw.eventLog.logEvent : function () {};
@Nikerabbit

This comment has been minimized.

Copy link

commented Jun 15, 2013

You are missing [] form line 4. On line 11 there is extra ), On line 26 missing ) and after that missing "return true".

@atdt

This comment has been minimized.

Copy link
Owner Author

commented Jul 9, 2013

Eep. Fixed.

@prtksxna

This comment has been minimized.

Copy link

commented Feb 27, 2014

I think there still is an extra ) on L11. There needs to be , at the end of L15/25 and another ) on L16.

@legoktm

This comment has been minimized.

Copy link

commented Jun 2, 2015

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 can’t perform that action at this time.