Hooks class.
More...
|
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 | 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, array $args=[], $deprecatedVersion=null) |
| Call hook functions defined in Hooks::register and $wgHooks.
|
|
static | runWithoutAbort ( $event, array $args=[], $deprecatedVersion=null) |
| Call hook functions defined in Hooks::register and $wgHooks.
|
|
|
static | $handlers = [] |
| Array of events mapped to an array of callbacks to be run when that event is triggered.
|
|
|
static | callHook ( $event, $hook, array $args, $deprecatedVersion=null, &$fname=null) |
|
Hooks class.
Used to supersede $wgHooks, because globals are EVIL.
- Since
- 1.18
Definition at line 34 of file Hooks.php.
◆ callHook()
static Hooks::callHook |
( |
|
$event, |
|
|
|
$hook, |
|
|
array |
$args, |
|
|
|
$deprecatedVersion = null , |
|
|
& |
$fname = null |
|
) |
| |
|
staticprivate |
- Parameters
-
string | $event | Event name |
array | callable | $hook | |
array | $args | Array of parameters passed to hook functions |
string | null | $deprecatedVersion | [optional] |
string | &$fname | [optional] Readable name of hook [returned] |
- Returns
- null|string|bool
Definition at line 116 of file Hooks.php.
References $args, and wfDeprecated().
◆ clear()
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 | $name | The name of the hook to clear. |
- Since
- 1.21
- Exceptions
-
Definition at line 63 of file Hooks.php.
◆ getHandlers()
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 | $name | Name of the hook |
- Returns
- array
Definition at line 94 of file Hooks.php.
References $wgHooks.
◆ isRegistered()
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
-
- Returns
- bool True if the hook has a function registered to it
Definition at line 80 of file Hooks.php.
References $wgHooks.
◆ register()
static Hooks::register |
( |
|
$name, |
|
|
|
$callback |
|
) |
| |
|
static |
Attach an event handler to a given hook.
- Parameters
-
string | $name | Name of hook |
callable | $callback | Callback function to attach |
- Since
- 1.18
Definition at line 49 of file Hooks.php.
◆ run()
static Hooks::run |
( |
|
$event, |
|
|
array |
$args = [] , |
|
|
|
$deprecatedVersion = null |
|
) |
| |
|
static |
Call hook functions defined in Hooks::register and $wgHooks.
For the given 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.
For hook event that are not abortable through a handler's return value, use runWithoutAbort() instead.
- Parameters
-
string | $event | Event name |
array | $args | Array of parameters passed to hook functions |
string | null | $deprecatedVersion | [optional] Mark hook as deprecated with version number |
- Returns
- bool True if no handler aborted the hook
- Exceptions
-
- 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.
Definition at line 200 of file Hooks.php.
References $args.
◆ runWithoutAbort()
static Hooks::runWithoutAbort |
( |
|
$event, |
|
|
array |
$args = [] , |
|
|
|
$deprecatedVersion = null |
|
) |
| |
|
static |
Call hook functions defined in Hooks::register and $wgHooks.
- Parameters
-
string | $event | Event name |
array | $args | Array of parameters passed to hook functions |
string | null | $deprecatedVersion | [optional] Mark hook as deprecated with version number |
- Returns
- bool Always true
- Exceptions
-
MWException | If a callback is invalid, unknown |
UnexpectedValueException | If a callback returns an abort value. |
- Since
- 1.30
Definition at line 231 of file Hooks.php.
References $args.
◆ $handlers
Array of events mapped to an array of callbacks to be run when that event is triggered.
Definition at line 39 of file Hooks.php.
The documentation for this class was generated from the following file: