-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
Description
Currently, decorating event listeners (kernel.event_listener
) makes the decorated service private:
https://github.com/symfony/dependency-injection/blob/5d4f4ff02a3a5b24a7c81bb7e22f2e57c7526ee2/Compiler/DecoratorServicePass.php#L47-L58
resulting in an exception being thrown here:
symfony/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php
Lines 61 to 63 in 94078a0
if (!$def->isPublic()) { | |
throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event listeners are lazy-loaded.', $id)); | |
} |
This makes it impossible to decorate event listeners. (Also, I can't find any tests of decorating event listeners. Are there any?)