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.
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
ErrorListeneris autowired for the API-PlatformExceptionListenerwith the use of its concrete implementation. When decorating the SymfonyErrorListnerthe decorated class is passed to the API-PlatformExceptionListener. This will cause an issue as the decorated service is not an instance ofSymfony\Component\HttpKernel\EventListener\ErrorListener. This will fail with an exception while loading the application.How to reproduce
Decorate the
Symfony\Component\HttpKernel\EventListener\ErrorListenerfollowing the SF-Guidelines https://symfony.com/doc/current/service_container/service_decoration.htmlPossible Solution
One obvious solution would presume change in Symfony: If the
Symfony\Component\HttpKernel\EventListener\ErrorListenerwould 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.