refactor: extract duplicate sendJson() and browseSnapshot logic from controllers #173
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
Two pieces of code are duplicated across
AjaxControllerandSnapshotsController:sendJson()method — identical private method in both controllers (AjaxController:1388 and SnapshotsController:242)AjaxController::browseSnapshot()andSnapshotsController::browse()perform nearly identical AJAX snapshot browsing with the same query, data formatting, and JSON response patternLocations
src/Controller/AjaxController.php:1388—private function sendJson()src/Controller/SnapshotsController.php:242—private function sendJson()src/Controller/AjaxController.php—browseSnapshot()methodsrc/Controller/SnapshotsController.php—browse()methodWhat to do
sendJson()into a shared trait (e.g.,JsonResponseTrait) used by both controllersWhy
Duplicate code means bug fixes must be applied in two places. The
sendJson()duplication is pure copy-paste; the browse logic duplication means snapshot browsing could diverge between the two entry points.Branch created:
feature/173-refactor-extract-duplicate-sendjson-and-Confirmed @ 02.56.05 — keep open.
sendJson()is still duplicated verbatim inAjaxController.php:1271andSnapshotsController.php:242(no shared trait). Browse logic also still in both:AjaxController::browseSnapshot()(:655) andSnapshotsController::browse()(:113). Line ref updated:sendJson()is now atAjaxController.php:1271(was 1388 in the title — line drift only).