Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
hooks/trigger/basic.php

Trigger a Plugin Hook and run all handler callbacks registered to that hook:type.This function runs all handlers registered to $hook, $type or the special keyword 'all' for either or both.

Use $params to send additional information to the handler callbacks.

$returnvalue is the initial value to pass to the handlers, which can change it by returning non-null values. It is useful to use $returnvalue to set defaults. If no handlers are registered, $returnvalue is immediately returned.

Handlers that return null (or with no explicit return or return value) will not change the value of $returnvalue.

$hook is usually a verb: import, get_views, output.

$type is usually a noun: user, ecml, page.

Like Elgg Events, $hook and $type can use the special keyword 'all'. Handler callbacks registered with $hook = all will be called for all hooks of type $type. Similarly, handlers registered with $type = all will be called for all hooks of type $event, regardless of $object_type. If $hook and $type both are 'all', the handler will be called for all hooks.

It's not possible for a plugin hook to change a non-null $returnvalue to null.

Note
Internal: The checks for $hook and/or $type not being equal to 'all' is to prevent a plugin hook being registered with an 'all' being called more than once if the trigger occurs with an 'all'. An example in core of this is in actions.php: elgg_trigger_plugin_hook('action_gatekeeper:permissions:check', 'all', ...)
See Also
elgg_register_plugin_hook_handler()
Parameters
string$hookThe name of the hook to trigger ("all" will trigger for all $types regardless of $hook value)
string$typeThe type of the hook to trigger ("all" will trigger for all $hooks regardless of $type value)
mixed$paramsAdditional parameters to pass to the handlers
mixed$returnvalueAn initial return value
Returns
mixed|null The return value of the last handler callback called
Trigger a hook that determines if execution
                                should continue.