Sha256: efe0f8d9e451b96771f572547839c748d1f8103147a13a989756fcc334f0117e

Contents?: true

Size: 915 Bytes

Versions: 5

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # A helper to get the root path for a feature.
  module FeaturePathHelper
    # Returns the defined root path for a given feature.
    #
    # feature - the Feature we want to find the root path for.
    #
    # Returns a url.
    def main_feature_path(feature)
      feature_root_path_for(feature.manifest.engine, feature)
    end

    # Returns the defined admin root path for a given feature.
    #
    # feature - the Feature we want to find the root path for.
    #
    # Returns a url.
    def manage_feature_path(feature)
      feature_root_path_for(feature.manifest.admin_engine, feature)
    end

    private

    def feature_root_path_for(engine, feature)
      url_params = {
        feature_id: feature.id,
        participatory_process_id: feature.participatory_process.id
      }

      engine.routes.url_helpers.root_path(url_params)
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
decidim-core-0.5.1 app/helpers/decidim/feature_path_helper.rb
decidim-0.5.1 decidim-core/app/helpers/decidim/feature_path_helper.rb
decidim-core-0.5.0 app/helpers/decidim/feature_path_helper.rb
decidim-0.5.0 decidim-core/app/helpers/decidim/feature_path_helper.rb
decidim-core-0.4.4 app/helpers/decidim/feature_path_helper.rb