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?
CiviCRM Stack Exchange is a question and answer site for administrators and users of the CiviCRM Constituent Relationship Management software. It only takes a minute to sign up.
Sign up to join this communityThe API kernel uses a symfony event system at it's heart.
How on earth do I find out where all those events are going?
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);
}
}