31,024
edits
No edit summary Tag: 2017 source edit |
Tag: 2017 source edit |
||
| Line 112: | Line 112: | ||
<syntaxHighlight lang="php"> | <syntaxHighlight lang="php"> | ||
// Call trigger | // Call trigger | ||
$result = $this->call_trigger('XXXXX_YYYYY', $user); | $result = $this->call_trigger('XXXXX_YYYYY', $user); | ||
if ($result <0) $error++; | if ($result <0) $error++; | ||
// End call triggers | // End call triggers | ||
</syntaxHighlight> | </syntaxHighlight> | ||
To add context information (for example to dissociate 2 different cases called with the same Trigger code), it is possible to place this information in the properties ->context of the object on which the trigger is called. Example: | |||
// Call trigger | |||
$this->context = array('paramX'=>$valueX, 'anyparamofyourchoice'=>$anyvalue); | |||
$result=$this->call_trigger('XXXXX_YYYYY',$user); | |||
if ($result < 0) $error++; | |||
// End call triggers | |||
It will then be possible to add in the run_trigger method of any trigger file, an if which allows you to manage this code. The run_trigger method would then be of the form: | It will then be possible to add in the run_trigger method of any trigger file, an if which allows you to manage this code. The run_trigger method would then be of the form: | ||