[API] Add getWrappedDriver method to AbstractDriverMiddleware
Feature Request
There are cases when it's required to extact$wrappedDriver but AbstractDriverMiddleware does not have such public api.
https://github.com/DamienHarper/auditor/issues/184
| Q | A |
|---|---|
| New Feature | yes |
| RFC | yes |
Summary
Adding get-method for $wrappedDriver
There are cases when it's required to extact
$wrappedDriver
And which cases would that be? The middleware stacks are not designed to be unwrapped and that's kind of on purpose.
but
AbstractDriverMiddlewaredoes not have such public api.
Please be aware that AbstractDriverMiddleware is by no means a contract. It's a utility class. The contract of a driver middleware class is the Driver interface. A class that only implements that interface and not the abstract class is still a valid driver middleware class.
So, even if we did add such a method to AbstractDriverMiddleware, it would not guarantee that you could actually unwrap the whole driver stack.
I don't know what problem you are trying to solve, but I would kindly ask you to find a different way.
Case is mentioned here https://github.com/DamienHarper/auditor/issues/184 and https://github.com/DamienHarper/auditor/blob/8edca5bedfda2f838003471321c60c45d941ba03/src/Provider/Doctrine/Auditing/Event/DoctrineSubscriber.php#L37-L42
this could be a wrong implementation from auditor lib, but it's OCP, we decorate connection/driver to add extra functionality - so imo valid solution to check instance if needed, but because driver/connection could be wrapped by many other decorators logic could be broken, that's why need to rewind or unwrap.