Class: Decidim::Components::BaseController

Inherits:
ApplicationController show all
Includes:
NeedsPermission, ParticipatorySpaceContext, Settings
Defined in:
app/controllers/decidim/components/base_controller.rb

Overview

Controller from which all component engines inherit from. It is in charge of setting the appropriate layout, including necessary helpers, and overall fooling the engine into thinking it is isolated.

Direct Known Subclasses

LikesController

Instance Method Summary collapse

Methods included from RegistersPermissions

register_permissions

Methods inherited from ApplicationController

#store_share_token

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from TranslatableAttributes

#attachment?, #default_locale?

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#current_componentObject



45
46
47
# File 'app/controllers/decidim/components/base_controller.rb', line 45

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

#current_manifestObject



49
50
51
# File 'app/controllers/decidim/components/base_controller.rb', line 49

def current_manifest
  @current_manifest ||= current_component.manifest
end

#current_participatory_spaceObject



41
42
43
# File 'app/controllers/decidim/components/base_controller.rb', line 41

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

#permission_class_chainObject



57
58
59
60
61
62
63
64
# File 'app/controllers/decidim/components/base_controller.rb', line 57

def permission_class_chain
  [
    current_component.manifest.permissions_class,
    current_participatory_space.manifest.permissions_class,
    Decidim::Admin::Permissions,
    Decidim::Permissions
  ]
end

#permission_scopeObject



53
54
55
# File 'app/controllers/decidim/components/base_controller.rb', line 53

def permission_scope
  :public
end

#redirect_unless_feature_privateObject

Raises:

  • (ActionController::RoutingError)


66
67
68
# File 'app/controllers/decidim/components/base_controller.rb', line 66

def redirect_unless_feature_private
  raise ActionController::RoutingError, "Not Found" unless current_user_can_visit_space?
end

#set_breadcrumb_itemsObject



70
71
72
73
74
# File 'app/controllers/decidim/components/base_controller.rb', line 70

def set_breadcrumb_items
  context_breadcrumb_items << add_current_component
  context_breadcrumb_items << add_parent_breadcrumb_item
  context_breadcrumb_items << add_breadcrumb_item
end