New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Events support for Command #11064
Conversation
a33b9e9
to
b07606e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have gone through the code as well as tested this by adding the following initializer code in the development application:
log_path = Rails.root.join("log/testing_events.log")
logger = Logger.new(log_path)
logger.info("Started the application!")
Decidim::EventsManager.subscribe("decidim.admin.block_user:before") do |event_name, data|
logger.info("Block user -- BEFORE")
logger.info(event_name.inspect)
logger.info(data.inspect)
end
Decidim::EventsManager.subscribe("decidim.admin.block_user:after") do |event_name, data|
logger.info("Block user -- AFTER")
logger.info(event_name.inspect)
logger.info(data.inspect)
end
It worked great and logged both events when I blocked a user.
Overall I really like the approach, I have just left a couple of comments regarding some code clarification and regarding the with_events
method itself which I think could be simplified.
Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more remark and this is good to go for me.
There may be a reason for this but I didn't understand it.
🎩 What? Why?
In the review of #10151, @ahukkanen suggested to use a hook method in the commands so that we can easily issue ActiveSupport Notifications that can be subscribed to from various places of Decidim application. While implementing this, i have seen that we already have some other events that we dispatch, so, in order to have a consolidated mode of issuing application wide events, i have created this PR.
📌 Related Issues
Link your PR to an issue
Testing
Follow the test scenarios in #6804 and #10111