1

The API kernel uses a symfony event system at it's heart.

How on earth do I find out where all those events are going?

1
1

This maybe not best practice but something like this will list all the events and their handlers:

 $kernel = \Civi::service('civi_api_kernel');                                
 $this->dispatcher = $kernel->getDispatcher();                             
 $listeners = $this->dispatcher->getListeners();                             
 foreach ($listeners as $event => $event_listeners) {                        
   echo "\n\n# $event\n";                                                    
   foreach ($event_listeners as $n => $listener) {                           
     echo "\n## Listener $n";
     $reflection = new \ReflectionClass($listener[0]);                       
     echo $reflection->getName() . "::" . ($listener[1]);
     echo "\nsource: " . $reflection->getFileName()                          
       . " lines: " . $reflection->getStartLine()
       . "-" . $reflection->getEndLine();
     // echo "\n Methods:" . json_encode(get_class_methods($listener[0]),JSON_PRETTY_PRINT);
   }   
 } 

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.