[ticket/12653] Caches the listeners and register them as service listener

https://tracker.phpbb.com/browse/PHPBB3-12653

PHPBB3-12653
I mean that `foreach ($listeners as $listener)` should be foreach `foreach ($listeners as $service_id = >$method_to_call)`