summaryrefslogtreecommitdiffstats
path: root/lib/redmine/hook.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-10-19 18:03:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-10-19 18:03:25 +0000
commit9244f67e286233d80ea7f55c368db1a38704b8ef (patch)
treedae37191a1465d790e9a033ee3e5c6535bbb48b8 /lib/redmine/hook.rb
parent7356e18d36a6501ff0bce2434a5162f7a47ecb1a (diff)
downloadredmine-9244f67e286233d80ea7f55c368db1a38704b8ef.tar.gz
redmine-9244f67e286233d80ea7f55c368db1a38704b8ef.zip
Extract classes to their own files to prevent loading issues (#20508).
git-svn-id: http://svn.redmine.org/redmine/trunk@14694 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/hook.rb')
-rw-r--r--lib/redmine/hook.rb71
1 files changed, 0 insertions, 71 deletions
diff --git a/lib/redmine/hook.rb b/lib/redmine/hook.rb
index fc5692cab..1328a4413 100644
--- a/lib/redmine/hook.rb
+++ b/lib/redmine/hook.rb
@@ -64,77 +64,6 @@ module Redmine
end
end
- # Base class for hook listeners.
- class Listener
- include Singleton
- include Redmine::I18n
-
- # Registers the listener
- def self.inherited(child)
- Redmine::Hook.add_listener(child)
- super
- end
-
- end
-
- # Listener class used for views hooks.
- # Listeners that inherit this class will include various helpers by default.
- class ViewListener < Listener
- include ERB::Util
- include ActionView::Helpers::TagHelper
- include ActionView::Helpers::FormHelper
- include ActionView::Helpers::FormTagHelper
- include ActionView::Helpers::FormOptionsHelper
- include ActionView::Helpers::JavaScriptHelper
- include ActionView::Helpers::NumberHelper
- include ActionView::Helpers::UrlHelper
- include ActionView::Helpers::AssetTagHelper
- include ActionView::Helpers::TextHelper
- include Rails.application.routes.url_helpers
- include ApplicationHelper
-
- # Default to creating links using only the path. Subclasses can
- # change this default as needed
- def self.default_url_options
- {:only_path => true, :script_name => Redmine::Utils.relative_url_root}
- end
-
- # Helper method to directly render using the context,
- # render_options must be valid #render options.
- #
- # class MyHook < Redmine::Hook::ViewListener
- # render_on :view_issues_show_details_bottom, :partial => "show_more_data"
- # end
- #
- # class MultipleHook < Redmine::Hook::ViewListener
- # render_on :view_issues_show_details_bottom,
- # {:partial => "show_more_data"},
- # {:partial => "show_even_more_data"}
- # end
- #
- def self.render_on(hook, *render_options)
- define_method hook do |context|
- render_options.map do |options|
- if context[:hook_caller].respond_to?(:render)
- context[:hook_caller].send(:render, {:locals => context}.merge(options))
- elsif context[:controller].is_a?(ActionController::Base)
- context[:controller].send(:render_to_string, {:locals => context}.merge(options))
- else
- raise "Cannot render #{self.name} hook from #{context[:hook_caller].class.name}"
- end
- end
- end
- end
-
- def controller
- nil
- end
-
- def config
- ActionController::Base.config
- end
- end
-
# Helper module included in ApplicationHelper and ActionController so that
# hooks can be called in views like this:
#