DEV: Change Bookmarkable registration to DiscoursePluginRegistry (#20556)

Similar spirit to e195e6f614de7a4c4f151ad947578fb69f8917f0,
this moves the Bookmarkable registration to DiscoursePluginRegistry
so plugins which are not enabled do not register additional
bookmarkable classes.
This commit is contained in:
Martin Brennan
2023-03-08 10:39:12 +10:00
committed by GitHub
parent 1c881c1037
commit 360d0dde65
16 changed files with 43 additions and 46 deletions

View File

@ -1221,6 +1221,16 @@ class Plugin::Instance
DiscoursePluginRegistry.register_user_destroyer_on_content_deletion_callback(callback, self)
end
##
# Register a class that implements [BaseBookmarkable], which represents another
# [ActiveRecord::Model] that may be bookmarked via the [Bookmark] model's
# polymorphic association. The class handles create and destroy hooks, querying,
# and reminders among other things.
def register_bookmarkable(klass)
return if Bookmark.registered_bookmarkable_from_type(klass.model.name).present?
DiscoursePluginRegistry.register_bookmarkable(RegisteredBookmarkable.new(klass), self)
end
protected
def self.js_path