Sha256: f56ad549f60d5b3c080dd7f4087c4a8116214086531cbf6e53df979e8a7d1113
Contents?: true
Size: 1.75 KB
Versions: 11
Compression:
Stored size: 1.75 KB
Contents
module CamaleonCms module HooksHelper include CamaleonCms::PluginsHelper # execute hooks for plugin_key with action name hook_key # non public method # plugin: plugin configuration (config.json) # hook_key: hook key # params: params for hook def hook_run(plugin, hook_key, params = nil) _do_hook(plugin, hook_key, params) end # execute all hooks from enabled plugins with key hook_key # non public method # hook_key: hook key # params: params for hook def hooks_run(hook_key, params = nil) PluginRoutes.enabled_apps(current_site).each do |plugin| _do_hook(plugin, hook_key, params) end # call all anonymous hooks PluginRoutes.get_anonymous_hooks(hook_key).each do |_hook| _hook.call(params) end end # skip hook function with name: hook_function_name def hook_skip(hook_function_name) @_hooks_skip << hook_function_name end private def _do_hook(plugin, hook_key, params = nil) return if !plugin.present? || !plugin['hooks'].present? || !plugin['hooks'][hook_key].present? plugin['hooks'][hook_key].each do |hook| next if @_hooks_skip.present? && @_hooks_skip.include?(hook) begin if params.nil? send(hook) else send(hook, params) end Rails.logger.debug "Camaleon CMS - Hook \"#{hook_key}\" executed from dependency #{begin plugin['key'] rescue StandardError '' end}".cama_log_style(:light_blue) rescue StandardError plugin_load_helpers(plugin) if params.nil? send(hook) else send(hook, params) end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems