Sha256: 18f09c579138bd2034e1a50b0f78f201ad67eb84702f1265f6f7f2047410a0bc
Contents?: true
Size: 1.25 KB
Versions: 17
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module Decidim module Admin # This command deals with destroying a Component from the admin panel. class DestroyComponent < Decidim::Command # Public: Initializes the command. # # component - The Component to be destroyed. # current_user - the user performing the action def initialize(component, current_user) @component = component @current_user = current_user end # Public: Executes the command. # # Broadcasts :ok if it got destroyed, raises an exception otherwise. def call begin destroy_component rescue StandardError return broadcast(:invalid) end broadcast(:ok) end private def destroy_component transaction do run_before_hooks Decidim.traceability.perform_action!( "delete", @component, @current_user ) do @component.destroy! end run_hooks end end def run_before_hooks @component.manifest.run_hooks(:before_destroy, @component) end def run_hooks @component.manifest.run_hooks(:destroy, @component) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems