5 elgg.provide(
'elgg.config.hooks');
6 elgg.provide(
'elgg.config.instant_hooks');
7 elgg.provide(
'elgg.config.triggered_hooks');
24 elgg.register_hook_handler =
function(name,
type, handler, priority) {
25 elgg.assertTypeOf(
'string', name);
26 elgg.assertTypeOf(
'string', type);
27 elgg.assertTypeOf(
'function', handler);
33 var priorities =
elgg.config.hooks;
35 elgg.provide(name +
'.' + type, priorities);
37 if (!(priorities[name][type] instanceof
elgg.ElggPriorityList)) {
38 priorities[name][
type] =
new elgg.ElggPriorityList();
42 if (
elgg.is_instant_hook(name, type) &&
elgg.is_triggered_hook(name, type)) {
43 handler(name, type, null, null);
46 return priorities[name][
type].insert(handler, priority);
73 elgg.trigger_hook =
function(name,
type, params, value) {
74 elgg.assertTypeOf(
'string', name);
75 elgg.assertTypeOf(
'string', type);
78 elgg.set_triggered_hook(name, type);
81 value = !
elgg.isNullOrUndefined(value) ? value : null;
83 var hooks =
elgg.config.hooks,
84 tempReturnValue = null,
86 callHookHandler =
function(handler) {
87 tempReturnValue = handler(name, type, params, returnValue);
88 if (!
elgg.isNullOrUndefined(tempReturnValue)) {
89 returnValue = tempReturnValue;
93 elgg.provide(name +
'.' + type, hooks);
94 elgg.provide(
'all.' + type, hooks);
95 elgg.provide(name +
'.all', hooks);
96 elgg.provide(
'all.all', hooks);
100 if (name !=
'all' && type !=
'all') {
101 hooksList.push(hooks[name][type]);
105 hooksList.push(hooks[
'all'][type]);
109 hooksList.push(hooks[name][
'all']);
112 hooksList.push(hooks[
'all'][
'all']);
114 hooksList.every(
function(handlers) {
115 if (handlers instanceof
elgg.ElggPriorityList) {
116 handlers.forEach(callHookHandler);
137 elgg.register_instant_hook =
function(name,
type) {
138 elgg.assertTypeOf(
'string', name);
139 elgg.assertTypeOf(
'string', type);
141 return elgg.push_to_object_array(
elgg.config.instant_hooks, name, type);
151 return elgg.is_in_object_array(
elgg.config.instant_hooks, name, type);
161 return elgg.push_to_object_array(
elgg.config.triggered_hooks, name, type);
171 return elgg.is_in_object_array(
elgg.config.triggered_hooks, name, type);
174 elgg.register_instant_hook(
'init',
'system');
175 elgg.register_instant_hook(
'ready',
'system');
176 elgg.register_instant_hook(
'boot',
'system');