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
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.