ePages 6.11.0 - DE_EPAGES/Core/API/Hook.pm

Package DE_EPAGES::Core::API::Hook

Provides hooks functionality for cartridges that can't use the Trigger cartridge - because they don't rely on a database connection. Hooks and hook functions are configured in the file $ENV{EPAGES_CONFIG}/Hooks.conf The file has the format of an .ini file. Section names are hooks names, Keys are the hook function names and values specify the execution order.

Example
The Hooks.conf file looks like this:
[AppServerStartup]
COMPANY::Cartridge::Hooks::AppServerStartup::OnAppServerStartup=10
COMPANY2::Cartridge2::Hooks::AppServerStartup::OnAppServerStartup=20
@EXPORT_OK
TriggerCoreHook

Functions

TriggerCoreHook

TriggerCoreHook

Checks if external functions are hooked at this point and calls them if so, if multiple functions are hooked to the same hook they are called in the appropriate order. If the hook name does not exist, the function DIEs. The $hArgs hash is passed to each called function which can manipulate it.

Syntax
TriggerCoreHook($HookName, $hArgs);
Example
TriggerCoreHook('AppServerStartup', { Port => $self->port, Address => $self->address });
Input
$HookName (string)
name of hook
$hArgs (reference to hash)
arguments for hook functions, following keys are added by
this function:
  • HookCount - number of registered hook functions - integer
  • HookName - name of hook (copy of $HookName parameter)- string
  • HookCounter - actual function position - integer