$event =
$options['event'
] ?? null;
$dispatcherServiceName =
$options['dispatcher_service_name'
] ?? null;
$title = 'Registered listeners';
if (null !==
$dispatcherServiceName) { $title .=
sprintf(' of event dispatcher "%s"',
$dispatcherServiceName);
} if (null !==
$event) { $title .=
sprintf(' for event `%s` ordered by descending priority',
$event);
$registeredListeners =
$eventDispatcher->
getListeners($event);
} else { // Try to see if "events" exists
$registeredListeners = \
array_key_exists('events',
$options) ?
array_combine($options['events'
],
array_map(fn ($event) =>
$eventDispatcher->
getListeners($event),
$options['events'
])) :
$eventDispatcher->
getListeners();
} $this->
write(sprintf('# %s',
$title)."\n"
);
if (null !==
$event) { foreach ($registeredListeners as $order =>
$listener) { $this->
write("\n".
sprintf('## Listener %d',
$order + 1
)."\n"
);
$this->
describeCallable($listener);