- Redmine Plugin Extension and Development
- Alex Bevilacqua
- 211字
- 2021-07-16 12:20:24
Understanding hooks
A hook is essentially just a listener for which we've registered a callback function. These callback functions expect a single parameter: a hash that provides some context to the function. The contents of the hash depend on what type of hook is being evaluated.
There are four basic categories of hooks available in Redmine:
- View hooks
- Controller hooks
- Model hooks
- Helper hooks
For view and controller hooks, the context hash contains the following fields as well as data specific to the hook being used:
:project
: This is the current project:request
: This contains the current web request instance:controller
: This contains the current controller instance:hook_caller
: This holds the object that called the hook
Note
The full list of available hooks is maintained at http://www.redmine.org/projects/redmine/wiki/Hooks_List.
To quickly build the hook list for the version of Redmine you have installed, run the following commands:
cd /path/to/redmine/app grep -r call_hook *
By doing this from the app
directory, we prune out any results from the hook class definition or any of the test files.
Redmine has many hooks registered throughout the codebase by means of the call_hook
method, whose syntax is as follows:
call_hook(hook, context={})
For example, the partial /path/to/redmine/app/views/issues/_form.html.erb
contains the following hook declaration:
<%= call_hook(:view_issues_form_details_bottom, { :issue => @issue, :form => f }) %>
- C語言程序設計(第3版)
- 單片機C語言程序設計實訓100例:基于STC8051+Proteus仿真與實戰
- 假如C語言是我發明的:講給孩子聽的大師編程課
- 面向對象程序設計(Java版)
- 正則表達式經典實例(第2版)
- QGIS:Becoming a GIS Power User
- R Deep Learning Cookbook
- Mastering Linux Security and Hardening
- C語言程序設計習題與實驗指導
- 深入解析Java編譯器:源碼剖析與實例詳解
- 算法設計與分析:基于C++編程語言的描述
- Visual C++開發寶典
- 面向對象程序設計及C++(第3版)
- Wearable:Tech Projects with the Raspberry Pi Zero
- Mastering Object:Oriented Python(Second Edition)