BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
Hooks Class Reference

Static Public Member Functions

static register ($name, $callback)
 
static clear ($name)
 
static isRegistered ($name)
 
static getHandlers ($name)
 
static run ($event, array $args=[], $deprecatedVersion=null)
 

Static Protected Attributes

static $handlers = []
 

Detailed Description

Hooks class.

Used to supersede $wgHooks, because globals are EVIL.

Since
1.18

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.

Parameters
string$nameThe name of the hook to clear.
Since
1.21
Exceptions
MWExceptionIf not in testing mode.
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
Parameters
string$nameName of the hook
Returns
array
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
bool True if the hook has a function registered to it
static Hooks::register (   $name,
  $callback 
)
static

Attach an event handler to a given hook.

Parameters
string$nameName of hook
callable$callbackCallback function to attach
Since
1.18
static Hooks::run (   $event,
array  $args = [],
  $deprecatedVersion = null 
)
static

Call hook functions defined in Hooks::register and $wgHooks.

For a certain hook event, fetch the array of hook events and process them. Determine the proper callback for each hook and then call the actual hook using the appropriate arguments. Finally, process the return value and return/throw accordingly.

Parameters
string$eventEvent name
array$argsArray of parameters passed to hook functions
string | null$deprecatedVersionOptionally, mark hook as deprecated with version number
Returns
bool True if no handler aborted the hook
Exceptions
Exception
FatalError
MWException
Since
1.22 A hook function is not required to return a value for processing to continue. Not returning a value (or explicitly returning null) is equivalent to returning true.

$hook can be: a function, an object, an array of $function and $data, an array of just a function, an array of object and method, or an array of object, method, and data.

Member Data Documentation

Hooks::$handlers = []
staticprotected

Array of events mapped to an array of callbacks to be run when that event is triggered.


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