Sha256: dd398b1e8d1f7df5a313cffb3978b96d68db9eb358c307f556a12f02d6065c6b

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

module Decidim
  module Features
    # Controller from which all feature engines inherit from. It's in charge of
    # setting the appropiate layout, including necessary helpers, and overall
    # fooling the engine into thinking it's isolated.
    class BaseController < Decidim::ApplicationController
      include Settings
      include ActionAuthorization

      include ParticipatorySpaceContext
      participatory_space_layout

      helper Decidim::FiltersHelper
      helper Decidim::OrdersHelper
      helper Decidim::FeatureReferenceHelper
      helper Decidim::TranslationsHelper
      helper Decidim::IconHelper
      helper Decidim::ResourceHelper
      helper Decidim::ScopesHelper
      helper Decidim::ActionAuthorizationHelper
      helper Decidim::AttachmentsHelper
      helper Decidim::SanitizeHelper

      helper_method :current_feature,
                    :current_participatory_space,
                    :current_manifest

      skip_authorize_resource

      before_action do
        authorize! :read, current_feature
      end

      def current_participatory_space
        request.env["decidim.current_participatory_space"]
      end

      def current_feature
        request.env["decidim.current_feature"]
      end

      def current_manifest
        @current_manifest ||= current_feature.manifest
      end

      def ability_context
        super.merge(
          current_manifest: current_manifest,
          current_settings: current_settings,
          feature_settings: feature_settings
        )
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.9.3 app/controllers/decidim/features/base_controller.rb
decidim-core-0.9.2 app/controllers/decidim/features/base_controller.rb
decidim-core-0.9.1 app/controllers/decidim/features/base_controller.rb
decidim-core-0.9.0 app/controllers/decidim/features/base_controller.rb
decidim-core-0.8.4 app/controllers/decidim/features/base_controller.rb