mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 06:51:27 +08:00
DEV: Add framework for filtered plugin registers (#9763)
* DEV: Add framework for filtered plugin registers Plugins often need to add values to a list, and we need to filter those lists at runtime to ignore values from disabled plugins. This commit provides a re-usable way to do that, which should make it easier to add new registers in future, and also reduce repeated code. Follow-up commits will migrate existing registers to use this new system * DEV: Migrate user and group custom field APIs to plugin registry This gives us a consistent system for checking plugin enabled state, so we are repeating less logic. API changes are backwards compatible
This commit is contained in:
@ -146,27 +146,23 @@ class Plugin::Instance
|
||||
end
|
||||
|
||||
def whitelist_staff_user_custom_field(field)
|
||||
reloadable_patch do |plugin|
|
||||
::User.register_plugin_staff_custom_field(field, plugin) # plugin.enabled? is checked at runtime
|
||||
end
|
||||
DiscoursePluginRegistry.register_staff_user_custom_field(field, self)
|
||||
end
|
||||
|
||||
def whitelist_public_user_custom_field(field)
|
||||
reloadable_patch do |plugin|
|
||||
::User.register_plugin_public_custom_field(field, plugin) # plugin.enabled? is checked at runtime
|
||||
end
|
||||
DiscoursePluginRegistry.register_public_user_custom_field(field, self)
|
||||
end
|
||||
|
||||
def register_editable_user_custom_field(field, staff_only: false)
|
||||
reloadable_patch do |plugin|
|
||||
::User.register_plugin_editable_user_custom_field(field, plugin, staff_only: staff_only) # plugin.enabled? is checked at runtime
|
||||
if staff_only
|
||||
DiscoursePluginRegistry.register_staff_editable_user_custom_field(field, self)
|
||||
else
|
||||
DiscoursePluginRegistry.register_self_editable_user_custom_field(field, self)
|
||||
end
|
||||
end
|
||||
|
||||
def register_editable_group_custom_field(field)
|
||||
reloadable_patch do |plugin|
|
||||
::Group.register_plugin_editable_group_custom_field(field, plugin) # plugin.enabled? is checked at runtime
|
||||
end
|
||||
DiscoursePluginRegistry.register_editable_group_custom_field(field, self)
|
||||
end
|
||||
|
||||
def custom_avatar_column(column)
|
||||
|
Reference in New Issue
Block a user