Changes

m
Line 85: Line 85:     
<source lang="php">
 
<source lang="php">
class ActionsYourModuleName // extends CommonObject
+
class ActionsYourModuleName
 
{  
 
{  
 
   
 
   
Line 105: Line 105:  
         }
 
         }
   −
         $this->results=array('myreturn'=>$myvalue)
+
         if (! $error)
        $this->resprints='A text to show';
+
        {
+
            $this->results=array('myreturn'=>$myvalue)
         return 0;
+
            $this->resprints='A text to show';
 +
            return 0;
 +
        }
 +
        else
 +
         {
 +
            $this->errors[]='Error message';
 +
            return -1;
 +
        }
 
     }
 
     }
 
}  
 
}  
Line 122: Line 129:     
'''Returns''':
 
'''Returns''':
* The return code from a hook is 0 or 1 if success, negative if error.
+
* The return code from a hook is 0 or 1 if success, negative if error. 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 return code is negative, you can also set $this->errors[]='Error message to report to user'
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->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.