mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-09 18:20:16 +08:00
This commit adds `register_category_update_param_with_callback` to the
plugin API, allowing plugins to register category parameters and apply a
transactional callback relating to the param. The callback receives the
category instance and parameter value, and any exception raised will
roll back the category update.
Example usage:
```
register_category_param_with_transaction_callback(:doc_index_topic_id) do |category, value|
DocCategories::CategoryIndexManager.new(category).assign!(value)
end
```
In the example above, `doc_index_topic_id` will be added to
`permitted_params` in the category controller on update, and the
callback will be invoked on `after_update`, to ensure the category save
does not happen if the callback fails.
**Dev note**: I had considered creating a `CategoryExtension` and just
doing the typical `Category.prepend`, but I thought a plugin API is
probably better.
|
||
|---|---|---|
| .. | ||
| filter.rb | ||
| filter_manager.rb | ||
| instance.rb | ||
| metadata.rb | ||