Then, if we continue on this path, we need to remove the Doctrine\DBAL\Connection everywhere we use it, and replace it using MakinaCorpus\QueryBuilder\Bridge\Bridge instead. That's the easy one.
Now we are going to have one problem: backuppers and restorers are using Doctrine\Persistence\ManagerRegistry in order to create instances depending upon the database vendor. What I propose here would be:
Create a custom ConnectionConfig class, with all properties we need (name, username, password, host, port, vendor name, etc...).
Create a interface ConnectionRegistry { getSession(string $name): Bridge; getConfig(string $name): ConnectionConfig; } of our own, which would create the MakinaCorpus\QueryBuilder\Bridge\Bridge depending upon the ConnectionConfig internals.
For the Symfony bundle, we can implement this registry directly using the Doctrine\Persistence\ManagerRegistry and live with it, it's OK.
Use this custom registry in all our factories, in order to fetch either database session (for anonymizers for example) or the config object (for backkupers and restorers).
By doing that, we would have no DBAL hardcoded dependency left, only the glue code for Symfony.
In the long term, future: we can implement a custom one based upon a configuration file, which would use doctrine to actually create the connection, but in the future this would help in order create a standalone docker container or package.
OK, I have a plan, but we need to discuss it.
First, check https://github.com/makinacorpus/DbToolsBundle/pull/141 which unhardcode
doctrine/dbal
in many places.Then, if we continue on this path, we need to remove the
Doctrine\DBAL\Connection
everywhere we use it, and replace it usingMakinaCorpus\QueryBuilder\Bridge\Bridge
instead. That's the easy one.Now we are going to have one problem: backuppers and restorers are using
Doctrine\Persistence\ManagerRegistry
in order to create instances depending upon the database vendor. What I propose here would be:ConnectionConfig
class, with all properties we need (name, username, password, host, port, vendor name, etc...).interface ConnectionRegistry { getSession(string $name): Bridge; getConfig(string $name): ConnectionConfig; }
of our own, which would create theMakinaCorpus\QueryBuilder\Bridge\Bridge
depending upon theConnectionConfig
internals.Doctrine\Persistence\ManagerRegistry
and live with it, it's OK.By doing that, we would have no DBAL hardcoded dependency left, only the glue code for Symfony.
In the long term, future: we can implement a custom one based upon a configuration file, which would use doctrine to actually create the connection, but in the future this would help in order create a standalone docker container or package.