Hooks system: Difference between revisions

Jump to navigation Jump to search
added list of contexts and added a few infos in implementation
(added list of contexts and added a few infos in implementation)
Line 19: Line 19:
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($db);
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('modulecontext'));
$hookmanager->initHooks(array('context'));
</source>
</source>


''''modulecontext'''' is the module's context as a string. This is simply a indicator that hooking functions can use to detect which modules they want to hook (several different modules can have the same hooks names, but a hooking function may want to hook only one specific module and not the others).
$hookmanager->initHooks() takes 1 parameter (an array of contexts) and activate the hooks management for this script:
 
- ''''context'''' is the module's context as a string. This is simply a indicator that hooking functions can use to detect which modules they want to hook (several different modules can have the same hooks names, but a hooking function may want to hook only one specific module and not the others).
 
Note: you can set several contexts in the same script (for example if you want to break the functionnalities of your script into smaller parts, or if you are mixing several modules into one, for example when you do a bridge between modules or third-party application).




Line 112: Line 116:
Your function should now be called when you access the module/context and you will see the parameters and object and action.
Your function should now be called when you access the module/context and you will see the parameters and object and action.


= List of available Hooks =
= List of available Hooks in Dolibarr =
How to find a complete list of all available hooks ?  
How to find a complete list of all available hooks in Dolibarr's nomenclatura ?  
Just search for "'''executeHooks('''" through the code and you should easily find all the hooked methods calls.
Just search for "'''executeHooks('''" through the whole sourcecode (generally called "find in files") and you should easily find all the hooked methods calls.


This is however a small list of them (not complete):
This is however a small list of them (not complete):
{{ListOfHooks}}
{{ListOfHooks}}
...
...
Note: please note that this list may change in the future as hooks and contexts are added into Dolibarr, so if you really need to find a specific hooks, please search directly in the sourcecode.
= List of available Contexts in Dolibarr =
To find the complete list of available modules' context in Dolibarr's nomenclatura, the procedure is similar to finding hooks.
Search for "'''initHooks('''" through the whole sourcecode (generally called "find in files") and you should find all the possible contexts.
This is however a small list of them (not complete):
{{ListOfContexts}}
...
Note: please note that this list may change in the future as hooks and contexts are added into Dolibarr, so if you really need to find a specific hooks, please search directly in the sourcecode.


= See also =
= See also =
439

edits

Navigation menu