- 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 }) %>
- 軟件項目估算
- JSP網絡編程(學習筆記)
- Java EE 6 企業級應用開發教程
- C語言程序設計教程(第2版)
- Mastering Python Scripting for System Administrators
- Apex Design Patterns
- Linux Device Drivers Development
- 微信小程序入門指南
- Access 2010數據庫應用技術實驗指導與習題選解(第2版)
- 代替VBA!用Python輕松實現Excel編程
- Java Web應用開發給力起飛
- MySQL數據庫教程(視頻指導版)
- 讀故事學編程:Python王國歷險記
- Mastering R for Quantitative Finance
- 基于Docker的Redis入門與實戰