钩子系统: Difference between revisions

Jump to navigation Jump to search
Line 25: Line 25:
这将找到诸如“$reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action);”的结果,其中“addMoreBoxStatsCoustomer”是Hook名称。
这将找到诸如“$reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action);”的结果,其中“addMoreBoxStatsCoustomer”是Hook名称。


=添加/预埋hook以允许插入代码=
=添加/预埋hook点以允许插入代码=
要在您自己的模块中预埋hook(以便您的模块可以被其他模块“挂接”),您需要执行两个步骤。
要在您自己的模块中预埋hook(以便您的模块可以被其他模块“挂接”),您需要执行两个步骤。


Line 93: Line 93:
现在您的模块应该可以被挂接了,您可以按照下面的'''实现钩子'''中的过程来实现一个钩子函数,该函数将利用您刚才添加的hook(还可以测试它是否有效)。
现在您的模块应该可以被挂接了,您可以按照下面的'''实现钩子'''中的过程来实现一个钩子函数,该函数将利用您刚才添加的hook(还可以测试它是否有效)。


=实现钩子=
=实现Hook=


要使用钩子(即添加或覆盖部分代码),必须首先定义模块描述符(请参阅[[模块开发#创建模块描述符(必做)]])。然后,您必须执行以下步骤:
要使用钩子(即添加或覆盖部分代码),必须首先定义模块描述符(请参阅[[模块开发#创建模块描述符(必做)]])。然后,您必须执行以下步骤:
Line 189: Line 189:
*您的钩子还可以更改$object和$action的值。
*您的钩子还可以更改$object和$action的值。


=可用钩子列表=
=Dolibarr中可用的Hooks清单=
How to find a complete list of all available hooks in Dolibarr's nomenclatura ?
要查找Dolibarr中可用的挂钩点,只需在源代码中搜索“'''executeHooks('''”即可,您将很容易找到所有已预埋的挂钩点。
Just search for "'''executeHooks('''" through the whole sourcecode (generally called "find in files") and you should easily find all the hooked methods calls.
 
以下是一个可用的挂钩点清单(不完整):


This is however a small list of them (not complete):
{{ListOfHooks}}
{{ListOfHooks}}
...
...


Note: please note that this list may change in the future as hooks and contexts are added into Dolibarr, so if you really need to find a specific hooks, please search directly in the sourcecode.
请注意:此清单会随着版本升级而不断增长,因此如果您真的想知道是否存在特定的钩子或上下文,请使用上面列出的方法直接搜索源代码。
 
=Dolibarr中可用的上下文清单=
要查找Dolibarr中可用的上下文,查找过程类似于查找挂钩点。


=可用上下文列表=
在源代码中搜索“'''initHooks('''”,您将很容易找到所有已实现的上下文。
To find the complete list of available modules' context in Dolibarr's nomenclatura, the procedure is similar to finding hooks.
Search for "'''initHooks('''" through the whole sourcecode (generally called "find in files") and you should find all the possible contexts.


This is however a small list of them (not complete):
这是其中的一小部分(不完整):


{{ListOfContexts}}
{{ListOfContexts}}
...
...


Note: please note that this list may change in the future as hooks and contexts are added into Dolibarr, so if you really need to find a specific hooks, please search directly in the sourcecode.
请注意:此清单会随着版本升级而不断增长,因此如果您真的想知道是否存在特定的钩子或上下文,请使用上面列出的方法直接搜索源代码。


=参考=
=参考=


*[[Triggers]]
*[[触发系统|触发器]]
*[[Interfaces Dolibarr toward foreign systems]]
*[[Dolibarr到外部系统的接口]]
*[[Interfaces from foreign systems toward Dolibarr]]
*[[外部系统到Dolibarr的接口]]
714

edits

Navigation menu