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 Answer 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);
   }   
 } 
1
  • When I run this code I get "Cannot use object of type Closure as array".
    – Josh
    Feb 27 at 23:01

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.