You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The AbstractDbMapper provided by ZfcBase, and by extension ZfcUser's UserMapper, duplicate a ton of work that can easily be handed off to ZF2's built-in TableGateway system.
Building and executing SQL queries
Hydrating result of select() calls
Master/Slave adapter support
Utilizing TableGateway would strip ZfcUser's mapper down from ~400 lines (including AbstractDbMapper) to ~125 and remove the hard dependency on ZfcBase\Mapper\AbstractDbMapper, leaving ZfcUser's mapper as a just a thin wrapper around TableGateway that provides convenience methods (findBy*) and extracts entities passed to insert/update/delete methods.
One issue I've had with the previous mapper is with custom queries on the user table. AbstractDbMapper exposes getAdapter so you could do queries directly against that, but I found it better to just extend the mapper class and add a custom method for my query...which works fine until you get two modules that want a custom query each.
IMO the most straightforward solution would be to expose the TableGateway's selectWith method, though I'm not a fan of the encapsulation leak of having to know the database column names to build the query.
The AbstractDbMapper provided by ZfcBase, and by extension ZfcUser's UserMapper, duplicate a ton of work that can easily be handed off to ZF2's built-in TableGateway system.
Utilizing TableGateway would strip ZfcUser's mapper down from ~400 lines (including AbstractDbMapper) to ~125 and remove the hard dependency on
ZfcBase\Mapper\AbstractDbMapper
, leaving ZfcUser's mapper as a just a thin wrapper around TableGateway that provides convenience methods (findBy*) and extracts entities passed to insert/update/delete methods.An initial prototype of the refactoring can be diffed here. The modifications build on the result of #554, so I will submit a PR for this changeset once that PR has been completed.
The text was updated successfully, but these errors were encountered: