HookManager
class HookManager (View source)
Class to manage hooks
Properties
| DoliDB | $db | ||
| string | $error | ||
| string[] | $errors | ||
| string[] | $warnings | ||
| string[] | $contextarray | ||
| $hooks | array<string,array<string,null|string|CommonHookActions>> Array with instantiated classes |
||
| $hooksSorted | array<string,array<string,null|string|CommonHookActions>> Array with instantiated classes sorted by hook priority |
||
| array<string, array{name: string, contexts: string[], file: string, line: string, count: int}> | $hooksHistory | ||
| mixed[] | $resArray | ||
| string | $resPrint | ||
| int | $resNbOfHooks |
Methods
Init array $this->hooks with instantiated action controllers.
Execute hooks (if they were initialized) for the given method
Details
void
__construct(DoliDB|null $db)
Constructor
int<0, 1>
initHooks(string[] $arraycontext)
Init array $this->hooks with instantiated action controllers.
First, a hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS with value 'nameofcontext1:nameofcontext2:...' into $this->const of module descriptor file. This makes $conf->hooks_modules loaded with an entry ('modulename'=>array(nameofcontext1,nameofcontext2,...)) When initHooks function is called, with initHooks(list_of_contexts), an array $this->hooks is defined with instance of controller class found into file /mymodule/class/actions_mymodule.class.php (if module has declared the context as a managed context). Then when a hook executeHooks('aMethod'...) is called, the method aMethod found into class will be executed.
executeHooks(string $method, $parameters = array(), $object = null, $action = '')
Execute hooks (if they were initialized) for the given method
@phpstan-template T