Hooks system: Difference between revisions

Jump to navigation Jump to search
Line 59: Line 59:
Note2: If your hook can't be accessed, try to DISABLE then RENABLE your module for the hooks to be taken in account by Dolibarr (may not be required).
Note2: If your hook can't be accessed, try to DISABLE then RENABLE your module for the hooks to be taken in account by Dolibarr (may not be required).


= Usage =
= Implement the Hook =


To use a hook (add or replace a part of code), you first need to already have defined a module (see the wiki for that), and then you need to do 2 things:
To use a hook (add or replace a part of code), you first need to already have defined a module (see the wiki for that), and then you need to do 2 things:
Line 124: Line 124:
* If the method sets the property $this->results with an array, then the array $hookmanager->resArray will automatically be enriched with the contents of this array, which can be reused later.
* If the method sets the property $this->results with an array, then the array $hookmanager->resArray will automatically be enriched with the contents of this array, which can be reused later.
* If the method sets the property $this-> resprints with a string, then this string will be displayed by the manager hook (executeHook), immediately after your method exit.
* If the method sets the property $this-> resprints with a string, then this string will be displayed by the manager hook (executeHook), immediately after your method exit.
* Your code can also modify the value of $object and $action.


= List of available Hooks in Dolibarr =
= List of available Hooks in Dolibarr =

Navigation menu