Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] Decorating event listeners #19697

Closed
@teohhanhui

Description

@teohhanhui

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:

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?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions