DEV: Add add_controller_callback server side plugin api.

This commit is contained in:
Guo Xiang Tan 2020-05-11 16:26:43 +08:00
parent a3a464b838
commit 8233610d92
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20

View File

@ -235,6 +235,16 @@ class Plugin::Instance
end
end
def add_controller_callback(klass_name, callback, &block)
reloadable_patch do |plugin|
klass = klass_name.to_s.classify.constantize rescue klass_name.to_s.constantize
klass.public_send(callback) do |controller, action|
block.call(controller, action) if plugin.enabled?
end
end
end
# Add a post_custom_fields_whitelister block to the TopicView, respecting if the plugin is enabled
def topic_view_post_custom_fields_whitelister(&block)
reloadable_patch do |plugin|