Sha256: ca97e85ab658b6cc8415558787970a11e38b1098746bcb6351e889f7885276bd

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module TermCustomizer
    module Context
      class ControllerContext < Base
        def resolve!
          env = data[:headers].env
          controller = env["action_controller.instance"]

          @organization = env["decidim.current_organization"]

          # E.g. at the participatory process controller the
          # `decidim.current_participatory_space` environment variable has not
          # been set. Therefore, we need to fetch it directly from the
          # controller using its private method.
          @space =
            if controller.respond_to?(:current_participatory_space, true)
              controller.send(:current_participatory_space)
            else
              env["decidim.current_participatory_space"]
            end

          @component = env["decidim.current_component"]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-term_customizer-0.18.0 lib/decidim/term_customizer/context/controller_context.rb