0

I am looking for ways to trigger an event in my local dev to check out a custom event subscriber. The actual event is triggered by Google social auth and I don't think it is possible to do that locally.

Is it possible to trigger events using devel

1 Answer 1

5

You can use the event_dispatcher service to trigger an event, for example with \Drupal::service('event_dispatcher')->dispatch(MyModuleEvents::MY_EVENT, new MyModuleEventClass());.

You need to replace MyModuleEvents and MyModuleEventClass with the class names you are effectively using, and MyModuleEvents::MY_EVENT with the effective event name. (It is better to use a class constant.)

You can run the code using drush php "\Drupal::service('event_dispatcher')->dispatch(MyModuleEvents::MY_EVENT, new MyModuleEventClass());".

See Subscribe to and dispatch events for more details.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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