[Mediawiki-l] How best to set up hooks in an extension function ?

Richard Alan richard.philippines at gmail.com
Tue Jun 30 18:25:09 UTC 2009


I thought I had read somewhere that it was not a good idea to set
function hooks inside of a class in this way.
what follows is just one of many examples out there:

$wgExtensionFunctions[]        = 'wfSetupCSS'

function wfSetupCSS() {
    global $wgCSS;
    $wgCSS = new CSS();
}

class CSS {

    function CSS() {
        global $wgParser, $wgCSSMagic;
        $wgParser->setFunctionHook($wgCSSMagic, array($this, 'magicCss'));
        }


Any other suggestions on how to implement this type of functionality.
Would it be better not to instantiate the CSS
class and just use a static class with a function to set the hook like this:

$wgExtensionFunctions[]        = 'CSS::SetupCSS'

Where SetupCSS was a static function to set the hook.

Sorry if the question appears a bit dumb but I'm interested to hear
what the more experienced guys think.

Thanks,

Richard


More information about the MediaWiki-l mailing list