discourse/lib/plugin
Natalie Tay eb40b4f980
DEV: Plugin api for saving category attribute (#34898)
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.
2025-09-23 11:14:45 +08:00
..
filter.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
filter_manager.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
instance.rb DEV: Plugin api for saving category attribute (#34898) 2025-09-23 11:14:45 +08:00
metadata.rb DEV: Remove discourse-logster-rate-limit-checker from official plugins (#32727) 2025-05-15 09:10:15 +08:00