MediaWiki  REL1_21
Hooks Class Reference

Hooks class. More...

List of all members.

Static Public Member Functions

static clear ($name)
 Clears hooks registered via Hooks::register().
static getHandlers ($name)
 Returns an array of all the event functions attached to a hook This combines functions registered via Hooks::register and with $wgHooks.
static hookErrorHandler ($errno, $errstr)
 This REALLY should be protected...
static isRegistered ($name)
 Returns true if a hook has a function registered to it.
static register ($name, $callback)
 Attach an event handler to a given hook.
static run ($event, $args=array())
 Call hook functions defined in Hooks::register.

Static Protected Attributes

static $handlers = array()

Detailed Description

Hooks class.

Used to supersede $wgHooks, because globals are EVIL.

Since:
1.18

Definition at line 38 of file Hooks.php.


Member Function Documentation

static Hooks::clear ( name) [static]

Clears hooks registered via Hooks::register().

Does not touch $wgHooks. This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.

Since:
1.21
Parameters:
string$namethe name of the hook to clear.
Exceptions:
MWExceptionif not in testing mode.

Definition at line 52 of file Hooks.php.

References $name.

Referenced by PHPUnitMaintClass\finalSetup(), HooksTest\testNewStyleHookInteraction(), and HooksTest\testNewStyleHooks().

static Hooks::getHandlers ( name) [static]

Returns an array of all the event functions attached to a hook This combines functions registered via Hooks::register and with $wgHooks.

Since:
1.18
Exceptions:
MWException
FatalError
Parameters:
string$namename of the hook
Returns:
array

Definition at line 102 of file Hooks.php.

References $handlers, $name, $wgHooks, array(), empty, and global.

Referenced by run(), ContentHandler\runLegacyHooks(), and HooksTest\testNewStyleHookInteraction().

static Hooks::hookErrorHandler ( errno,
errstr 
) [static]

This REALLY should be protected...

but it's public for compatibility

Since:
1.18
Parameters:
int$errnoUnused
string$errstrerror message
Exceptions:
MWHookException
Returns:
Boolean: false

Definition at line 310 of file Hooks.php.

static Hooks::isRegistered ( name) [static]

Returns true if a hook has a function registered to it.

The function may have been registered either via Hooks::register or in $wgHooks.

Since:
1.18
Parameters:
string$namename of hook
Returns:
Boolean: true if the hook has a function registered to it

Definition at line 85 of file Hooks.php.

References $name, $wgHooks, empty, and global.

Referenced by ContentHandler\runLegacyHooks(), and HooksTest\testNewStyleHookInteraction().

static Hooks::register ( name,
callback 
) [static]

Attach an event handler to a given hook.

Since:
1.18
Parameters:
string$namename of hook
$callbackMixed: callback function to attach

Definition at line 68 of file Hooks.php.

References $name, and array().

Referenced by PHPUnitMaintClass\finalSetup(), HooksTest\testNewStyleHookInteraction(), HooksTest\testNewStyleHooks(), and ContentHandlerTest\testRunLegacyHooks().

static Hooks::run ( event,
args = array() 
) [static]

Call hook functions defined in Hooks::register.

Parameters:
string$eventevent name
$argsArray: parameters passed to hook functions
Exceptions:
MWException
FatalError
Returns:
Boolean True if no handler aborted the hook

Definition at line 144 of file Hooks.php.

References $retval, $wgHooks, array(), as, empty, functions, getHandlers(), global, like, strings, too, wfProfileIn(), and wfProfileOut().

Referenced by wfRunHooks().


Member Data Documentation

Hooks::$handlers = array() [static, protected]

Definition at line 40 of file Hooks.php.

Referenced by getHandlers().


The documentation for this class was generated from the following file: