aminin/airbrake-bundle

Cant deactivate bundle if using explicit DependancyInjection

Opened this issue · 0 comments

I am running in to a problem when trying to follow latest Symfony standards and disable the Notifier for dev/test environments.

I have a listener that grabs the service and adds context if the service is present. Up until recently I was inserting the container to this listener, checking if the Notifier was present and using it but as of Symfony 5.1 I'm getting this error

The "ami_airbrake.notifier" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

If I switch to direct injection everything is happy until I disable the service by setting the airbrake key to null (as per the docs) the service is not loaded and the compile fails.

I have worked around this problem this with my own services but substituting a Mock Service object instead of the real Notifier when in dev, I'd be happy to submit a PR that adds a NotifierInterface class that can be implemented by both real and Mock Services to make this possible if that'd be accepted or is there a more tidy solution?