Line 84:
Line 84:
<source lang="php">
<source lang="php">
−
<?php
−
class ActionsYourModuleName // extends CommonObject
class ActionsYourModuleName // extends CommonObject
{
{
Line 105:
Line 103:
// do something only for the context 'somecontext'
// do something only for the context 'somecontext'
}
}
+
+
$this->results=array('myreturn'=>$myvalue)
+
$this->resprints='A text to show';
+
+
return 0;
}
}
}
}
</source>
</source>
−
where
+
Your function should now be called when you access the module/context and you will see the parameters and object and action.
+
+
'''Where''':
* '''$parameters''' is an array of meta-data about the datas contained by the hook (eg: the context, always accessible by $parameters['context']).
* '''$parameters''' is an array of meta-data about the datas contained by the hook (eg: the context, always accessible by $parameters['context']).
* '''$object''' is the object that you may work on. Eg: the product if you are in the productcard context.
* '''$object''' is the object that you may work on. Eg: the product if you are in the productcard context.
* '''$action''' is the action if one is conveyed (generally "create", "edit" or "view").
* '''$action''' is the action if one is conveyed (generally "create", "edit" or "view").
−
Your function should now be called when you access the module/context and you will see the parameters and object and action.
+
'''Returns''':
+
* The return code from a hook is 0 or 1.
+
In general, it will be 0. It can be 1, which means that, in some specific cases, your code hook completely replaces what Dolibarr would do without the hook.
+
* 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.
= List of available Hooks in Dolibarr =
= List of available Hooks in Dolibarr =