after_initialize callback for plugins

This commit is contained in:
Sam 2013-09-17 10:23:21 +10:00
parent ba2c4139fe
commit 6af1e12cc1
2 changed files with 17 additions and 1 deletions

View File

@ -125,9 +125,12 @@ module Discourse
Discourse.activate_plugins! Discourse.activate_plugins!
end end
# So open id logs somewhere sane
config.after_initialize do config.after_initialize do
# So open id logs somewhere sane
OpenID::Util.logger = Rails.logger OpenID::Util.logger = Rails.logger
if plugins = Discourse.plugins
plugins.each{|plugin| plugin.notify_after_initialize}
end
end end
# This is not really required per-se, but we do not want to support # This is not really required per-se, but we do not want to support

View File

@ -67,6 +67,19 @@ class Plugin::Instance
File.dirname(path) << "/auto_generated" File.dirname(path) << "/auto_generated"
end end
def after_initialize(&block)
@after_initialize ||= []
@after_initialize << block
end
def notify_after_initialize
if @after_initialize
@after_initialize.each do |callback|
callback.call
end
end
end
def register_css(style) def register_css(style)
@styles ||= [] @styles ||= []
@styles << style @styles << style