Mumara Campaigns ships a small set of global helper functions that wrap the core Hooks class — these are what you use day-to-day when writing extension code.
The helpers fall into four groups:
Registration —
add_hook($hook, $priority, $callable)attaches a callback; lower priority numbers run first, and the callable can be a closure, a named function, or a class method.Execution —
listen_hook()fires all callbacks synchronously, whilerun_hook_in_background()queues aListenHookjob through Laravel's queue (it checks for registered callbacks first and returns immediately — use it for external APIs and heavy processing).Retrieval —
hook_get_output()returns the concatenated string from all callbacks (used to render HTML),hook_get()returns only the first callback's result, andhook_get_all()returns an array of every result.Utility —
hook_exist()tells you whether anything is registered, letting you skip unnecessary processing or conditional wrapper markup.
For advanced cases you can call the Hooks class statics directly (Hooks::add_hook, Hooks::listen, Hooks::getOutput, and so on). All helpers include built-in error handling: when enable_hooks_error_logging is on in Application Settings, hook errors are written to storage/logs/laravel.log. Useful patterns from the reference include validation chains via hook_get_all() plus array_filter(), and priority-based overrides where the lowest-priority callback wins when read with hook_get().
