Go to the source code of this file.
Registers a hook handler with the event system.
The special keyword "all" can be used for either the name or the type or both and means to call that handler for all of those hooks.
Note that handlers registering for instant hooks will be executed immediately if the instant hook has been previously triggered.
- Parameters
-
{String} | name The hook name. |
{String} | type The hook type. |
{Function} | handler Handler to call: function(hook, type, params, value) |
{Number} | priority Priority to call the event handler |
- Returns
- {Boolean}
Definition at line 5 of file hooks.js.
Initial value:=
function(object, parent,
value) {
elgg.assertTypeOf(
'object',
object);
elgg.assertTypeOf(
'string', parent);
return typeof(
object[parent]) !=
'undefined' && $.inArray(
value,
object[parent]) >= 0;
}
Tests if object[parent] contains child.
- Parameters
-
{Object} | object The object to add to |
{String} | parent The parent array to add to. |
{*} | value The value |
Definition at line 84 of file hooks.js.
Initial value: return elgg.is_in_object_array(
elgg.config.instant_hooks,
name, type);
}
Is this hook registered as an instant hook?
- Parameters
-
{String} | name The hook name. |
{String} | type The hook type. |
Definition at line 199 of file hooks.js.
Initial value: return elgg.is_in_object_array(
elgg.config.triggered_hooks,
name, type);
}
Has this hook been triggered yet?
- Parameters
-
{String} | name The hook name. |
{String} | type The hook type. |
Definition at line 219 of file hooks.js.
elgg push_to_object_array |
Initial value:=
function(object, parent,
value) {
elgg.assertTypeOf(
'object',
object);
elgg.assertTypeOf(
'string', parent);
if (!(object[parent] instanceof Array)) {
object[parent] = [];
}
if ($.inArray(
value,
object[parent]) < 0) {
return object[parent].push(
value);
}
return false;
}
Adds child to object[parent] array.
- Parameters
-
{Object} | object The object to add to |
{String} | parent The parent array to add to. |
{*} | value The value |
Definition at line 62 of file hooks.js.
elgg register_instant_hook |
Initial value: elgg.assertTypeOf(
'string', type);
return elgg.push_to_object_array(
elgg.config.instant_hooks,
name, type);
}
Registers a hook as an instant hook.
After being trigger once, registration of a handler to an instant hook will cause the handle to be executed immediately.
- Note
- Instant hooks must be triggered without params or defaults. Any params or default passed will not be passed to handlers executed upon registration.
- Parameters
-
{String} | name The hook name. |
{String} | type The hook type. |
- Returns
- {Number} integer
Definition at line 186 of file hooks.js.
Initial value: return elgg.push_to_object_array(
elgg.config.triggered_hooks,
name, type);
}
Records that a hook has been triggered.
- Parameters
-
{String} | name The hook name. |
{String} | type The hook type. |
Definition at line 209 of file hooks.js.
Emits a synchronous hook, calling only synchronous handlers.
Loops through all registered hooks and calls the handler functions in order. Every handler function will always be called, regardless of the return value.
- Warning
- Handlers take the same 4 arguments in the same order as when calling this function. This is different from the PHP version!
- Note
- Instant hooks do not support params or values.
Hooks are called in priority order.
- Parameters
-
{String} | name The hook name. |
{String} | type The hook type. |
{Object} | params Optional parameters to pass to the handlers |
{Object} | value Initial value of the return. Can be modified by handlers |
- Returns
- {*}
Definition at line 111 of file hooks.js.