Skip to content

Implementation of ExceptionListener prevents decoration possibility of Symfonys ErrorListener #4077

Description

@masonen

API Platform version(s) affected: ^2.5.x

Description
Current implementation of ExceptionListener prevents the possibility to decorate the Symfony\Component\HttpKernel\EventListener\ErrorListener.

The ErrorListener is autowired for the API-Platform ExceptionListener with the use of its concrete implementation. When decorating the Symfony ErrorListner the decorated class is passed to the API-Platform ExceptionListener. This will cause an issue as the decorated service is not an instance of Symfony\Component\HttpKernel\EventListener\ErrorListener. This will fail with an exception while loading the application.

How to reproduce
Decorate the Symfony\Component\HttpKernel\EventListener\ErrorListener following the SF-Guidelines https://symfony.com/doc/current/service_container/service_decoration.html

Possible Solution
One obvious solution would presume change in Symfony: If the Symfony\Component\HttpKernel\EventListener\ErrorListener would implement a dedicated interface this interface could be autowired instead of the concrete service implementation. This interface could than be implemented by the decorated service and should cause no issues.

Additional Context
Although one pretty straight forward approach to fix this is at hand I'd like to discuss further options here first before initiating a feature request on Symfonys end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions