触发系统: Difference between revisions

Jump to navigation Jump to search
Line 72: Line 72:
只要 ''run_trigger'' 函数根据以下原则返回一个返回代码,您就可以在这段代码中执行任何操作:
只要 ''run_trigger'' 函数根据以下原则返回一个返回代码,您就可以在这段代码中执行任何操作:


<0 失败,0 没有执行任何操作,>0 成功
<0(如果ko),0(如果没有执行任何操作),>0(如果ok)


此外,在此函数中,您可以使用以下对象:
此外,在此函数中,您可以使用以下对象:
Line 81: Line 81:
*'''$conf''' 是包含整个Dolibarr配置的对象。
*'''$conf''' 是包含整个Dolibarr配置的对象。


4) 代码开发完成后,只需在Dolibarr中触发触发事件即可进行测试。注意,函数 '''run_trigger''' 的调用被封装在事务中。如果触发器返回 KO 代码,调用函数可能会回滚事务(这取决于调用函数)。要在函数 '''run_trigger''' 中添加日志跟踪,用以确保代码运行良好。如果您愿意,可以使用函数 dol_syslog("my log message", LOG_DEBUG);
4) 代码开发完成后,只需在Dolibarr中触发触发事件即可进行测试。注意,函数 '''run_trigger''' 的调用被封装在事务中。如果触发器返回代码是 ko,调用函数可能会回滚事务(这取决于调用函数)。要在函数 '''run_trigger''' 中添加日志跟踪,用以确保代码运行良好。如果您愿意,可以使用函数 dol_syslog("my log message", LOG_DEBUG);


=List of known triggers actions=
=管理事件列表=


Here is a quick view of the events that cause triggers to be searched and executed. An event is characterized by the value of the code ''$action'', with the type of the object received in ''$object''.
以下是导致触发器被搜索和执行的事件的快速视图。事件的特征在于事件代码 ''$action'' 的值,以及在 ''$object'' 中接收的对象类型。


Note: The [[Module Agenda En|Module Agenda]] and [[Module Notification]] use the table [[Table llx c action trigger]] as a list of known triggers. This avoid scanning the disk for this information, but this table is just a very limited list.
注意:[[日程模块]] 和 [[Module Notification|通知模块]] 使用  [[Table llx c action trigger|表llx c action trigger]] 作为已知触发器的表。这避免了扫描磁盘以获取此信息,但此表仅包含非常有限的触发器列表。


In general, the trigger action code begins with the name of the module followed by the character _.
通常,触发事件代码 ''$action'' 以模块名称开头,后跟字符 _ 。


{{TemplateListOfTriggers}}
{{TemplateListOfTriggers}}
This list may be not complete.
此清单可能不完整。


=Manage and create a new trigger's action=
=创建新的触发器事件=


To manage events other than those above, you must modify the Dolibarr code to add the following sequence in the business methods of the classes of the objects handled:
要处理上述事件之外的其它事件,必须修改 Dolibarr 代码,以便在操作对象类的业务方法中添加以下序列:


<syntaxhighlight lang="PHP">
<syntaxhighlight lang="PHP">
Line 106: Line 106:
</syntaxhighlight>
</syntaxhighlight>


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:
然后,可以在任何触发器文件的 run_trigger 方法中添加一个 if 来管理该代码。run_trigger 方法的形式如下:


<syntaxhighlight lang="PHP">
<syntaxhighlight lang="PHP">
714

edits

Navigation menu