refactor: API controllers instantiate engines with new instead of DI container
#176
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Both API controllers (
api/src/Controller/BackupsController.phpandapi/src/Controller/SnapshotsController.php) create engine instances withnew BackupEngine(),new SnapshotEngine(), andnew SnapshotRestoreEngine()directly. This bypasses the DI container, making the engines untestable and preventing constructor injection of the database driver (related to #165).The same pattern exists in
AjaxControllerforSteppedBackupEngineandSteppedRestoreEngine.Locations
api/src/Controller/BackupsController.php:41—$engine = new BackupEngine();api/src/Controller/SnapshotsController.php:121—$engine = new SnapshotEngine();api/src/Controller/SnapshotsController.php:170—$engine = new SnapshotRestoreEngine();src/Controller/AjaxController.php—new SteppedBackupEngine(),new SteppedRestoreEngine()What to do
services/provider.phpDatabaseInterfacevia DI)Why
Direct
newinstantiation couples controllers to concrete classes, prevents unit testing with mocks, and blocks the DI-based database migration tracked in #165.