1

I want to write an implementation of EventSubscriberInterface for an event in commerce, there is a handy example, but

  1. How do I find out what events are available (as a whole for my site) and/or
  2. How do I know what events are getting hit on a request?

This question is not specific to the commerce module, it is just the context of my current problem.

  • \Symfony\Component\EventDispatcher\Event – user21641 Sep 14 '17 at 9:36
2

You can simply use the Drupal console.

List all the events that could be debugged:

drupal debug:event

drupal dev

Show the information for the specific event, for example "commerce_order.commerce_order.update":

drupal dev commerce_order.commerce_order.update

1

I was stumped by this for a while, so I was pleased to find an answer in the Devel module

Install the Devel module and look at the toolbar menu item:

"Events info" which links to /devel/events

So for the commerce events I can see the following:

Callable    Priority
commerce_order.place.post_transition
Drupal\commerce_order\EventSubscriber\OrderReceiptSubscriber::sendOrderReceipt  0

commerce_order.place.pre_transition
Drupal\commerce_cart\EventSubscriber\OrderEventSubscriber::finalizeCart 0
Drupal\commerce_order\EventSubscriber\TimestampEventSubscriber::onPlaceTransition   1
Drupal\commerce_order\EventSubscriber\OrderNumberSubscriber::setOrderNumber 2
  • 1
    Thanks @Duncanmoo, today you saved my life!!! – Beto Aveiga Aug 6 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.