Sha256: 8e15e7e020bd9f660d83c15802e635c17dee3f3999f09e554fdeb754723fd481

Contents?: true

Size: 910 Bytes

Versions: 4

Compression:

Stored size: 910 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 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

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.4.2 app/helpers/decidim/feature_path_helper.rb
decidim-core-0.4.1 app/helpers/decidim/feature_path_helper.rb
decidim-core-0.4.3 app/helpers/decidim/feature_path_helper.rb
decidim-core-0.4.0 app/helpers/decidim/feature_path_helper.rb