mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-31 11:03:22 +01:00
[PR #173] [MERGED] refactor(admin-api): extract admin/api.php into PSR-4 Ajax controllers #89
Closed
opened 2026-08-28 20:02:36 +02:00 by thegame_1980
·
0 comments
No Branch/Tag Specified
main
fix/admin-table-badge-contrast
feat/quick-tool-restart-high-memory
fix/stream-max-interleave-delta-cap
fix/player-api-live-added-string
fix/backup-undefined-extension-key
fix/serveonly-noderoot-certbot
fix/serveonly-install-preserve-config
fix/reseller-ui-prefs-persist
gh-pages
feat/lb-dataplane-serveonly-policy
docs/lb-single-binary-parity-audit
feat/serveonly-noderoot-sudoers
fix/serveonly-keep-nginx-ports
feat/lb-serve-only-node-mode
feat/lb-p6-install-php-free
fix/lb-policy-section-server-id
feat/lb-p2-selfheal-gate
feat/lb-p1-policy-section
feat/lb-certbot-webroot
feat/lb-migration-cleanup-recovery
feat/lb-serve-only-provisioning-gate
feat/lb-node-crontab-filter
docs/lb-stop-php-crons
docs/lb-rtmp-gates-design
feat/lb-single-binary-roadmap
2.7.2
2.7.1
2.7.0
2.6.7
2.6.6-p6
2.6.6-p5
2.6.6-p4
2.6.6-p3
2.6.6-p2
2.6.6-p1
2.6.6
2.6.5
2.6.4
2.6.3
2.6.2
2.6.1
2.6.0
2.5.3
2.5.2
2.5.1
2.5.0
2.4.3
2.4.2
2.4.1
2.4.0
2.3.9
2.3.8
2.3.7
2.3.6
2.3.5
2.3.4
2.3.3
2.3.2
2.3.1
2.2.2
2.2.1
2.2.0
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.2
2.0.1
2.0.0
1.2.16
1.2.15
1.2.14
1.2.13
1.2.12
1.2.11
1.2.10
1.2.9
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
Labels
Clear labels
Post-release verification
Review & Deploy
awaiting triage
bug
composer
dependencies
documentation
done
duplicate
enhancement
github-actions
good first issue
help wanted
in progress
incident
invalid
needs info
on hold
planned
pull-request
question
rejected
security
status: backlog
status: in progress
status: post-release verification
status: review & deploy
tech-debt
under consideration
wontfix
It is necessary to check whether the problem remains after the update
Board status (auto-synced from Projects v2)
Not yet reviewed/prioritized
Something isn't working
Composer bump: re-commit a production-only vendor (composer install --no-dev) after merging
Dependency update (Dependabot)
Improvements or additions to documentation
Successfully completed and ready for closure.
This issue or pull request already exists
New feature or request
GitHub Actions version bump
Good for newcomers
Extra attention is needed
Actively being worked on right now.
Production incident (outage/degradation)
This doesn't seem right
More information is needed before work can start.
Work is paused, pending external action or decision.
Approved and scheduled for future work.
Mirrored from GitHub Pull Request
Further information is requested
Will not be implemented.
Security-sensitive issue or fix
Board: Backlog (synced from the XC_VM board)
Board: In Progress (synced from the XC_VM board)
Board: released, waiting for confirmation (synced from the XC_VM board)
Board: Review & Deploy, merged and not released yet (synced from the XC_VM board)
Refactoring / cleanup / technical debt
Idea or proposal awaiting triage and decision.
This will not be worked on
No labels
pull-request
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Assignees
thegame_1980
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Vateron-Media/XC_VM#89
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/Vateron-Media/XC_VM/pull/173
Author: @Divarion-D
Created: 8/28/2026
Status: ✅ Merged
Merged: 8/28/2026
Merged by: @Divarion-D
Base:
main← Head:refactor/api-ajax-controllers📝 Commits (10+)
5c5ae46refactor(admin-api): extract Cache & Handlers actions into a controller8d4693drefactor(admin-api): extract Servers/Ops actions; move ajax controllers to Admin\Ajax0ba2241refactor(admin-api): flatten empty-then conditionals in ServerAjaxController905318erefactor(admin-api): extract Blocklists & Security actions into a controller2b271aerefactor(admin-api): extract Devices actions into a controllerba1eaa8refactor(admin-api): extract EPG actions into a controller7d6b196style(routes): normalize admin route section headersf6fad98refactor(admin-api): extract Users & Lines actions into a controllerfbdc719refactor(admin-api): extract Streams & VOD actions into controllers6e40de3refactor(admin-api): extract Packages, Bouquets & Groups actions into a controller📊 Changes
20 files changed (+4804 additions, -5010 deletions)
View changed files
➕
src/Public/Controllers/Admin/Ajax/BackupAjaxController.php(+206 -0)➕
src/Public/Controllers/Admin/Ajax/BaseAjaxController.php(+104 -0)➕
src/Public/Controllers/Admin/Ajax/BlocklistAjaxController.php(+212 -0)➕
src/Public/Controllers/Admin/Ajax/CacheAjaxController.php(+164 -0)➕
src/Public/Controllers/Admin/Ajax/DeviceAjaxController.php(+116 -0)➕
src/Public/Controllers/Admin/Ajax/EpgAjaxController.php(+428 -0)➕
src/Public/Controllers/Admin/Ajax/LineStateTrait.php(+87 -0)➕
src/Public/Controllers/Admin/Ajax/MiscAjaxController.php(+214 -0)➕
src/Public/Controllers/Admin/Ajax/MultiAjaxController.php(+360 -0)➕
src/Public/Controllers/Admin/Ajax/PackageAjaxController.php(+195 -0)➕
src/Public/Controllers/Admin/Ajax/ProviderAjaxController.php(+79 -0)➕
src/Public/Controllers/Admin/Ajax/SearchAjaxController.php(+833 -0)➕
src/Public/Controllers/Admin/Ajax/ServerAjaxController.php(+532 -0)➕
src/Public/Controllers/Admin/Ajax/StatsAjaxController.php(+388 -0)➕
src/Public/Controllers/Admin/Ajax/StreamAjaxController.php(+184 -0)➕
src/Public/Controllers/Admin/Ajax/StreamToolsAjaxController.php(+401 -0)➕
src/Public/Controllers/Admin/Ajax/UserAjaxController.php(+133 -0)📝
src/Public/Controllers/Admin/AjaxController.php(+20 -12)➖
src/Public/Views/admin/api.php(+0 -4985)📝
src/Public/routes/admin.php(+148 -13)📄 Description
Summary
Refactor the ~4985-line legacy
src/Public/Views/admin/api.php— a flat chain of ~90if (action == 'x') { … exit(); }blocks — into dedicated PSR-4 controllers, and retire the file entirely.Result:
admin/api.php4985 lines → removed; ~90 actions live in 16 controllers underPublic/Controllers/Admin/Ajax/.How it works
Each action is peeled off by registering
$router->api('action', [Ctrl::class, 'method'])inPublic/routes/admin.php.Public/index.phprunsRouter::dispatchApi($action)before theAjaxControllerfallback, so migration was incremental and behaviour-preserving — one action group at a time. Admin authentication is already enforced byAdminScopeBootstrap::boot()before dispatch. URL and JSON contracts are unchanged (/api?action=…still works).Building blocks
Ajax/BaseAjaxController— JSON-only base:ok()/fail()/gate()/gateAny()/requireXhr()/json().Ajax/LineStateTrait— shared enable/disable/ban/unban/kill sub-actions for the device and line controllers.Controllers
Cache · Server (Servers/Ops) · Blocklist · Device · Epg · User (Users & Lines) · Stream · StreamTools · Package · Stats · Backup · Provider · Misc · Search · Multi.
Notable points
search(848 lines) andmultiwere lifted byte-for-byte (verified identical), then their empty-thenif (c) {} else {…}idioms were flattened by a mechanical, negation-preserving pass;multiwas further de-nested into aswitch→ per-entity handler methods with shared helpers.reportkeeps its non-XHR, full-page-download behaviour (dispatchesTableControllerin-process).proxy → killread an undefined$rServerID(no-op + warnings in redis mode) — now usesserver_id.multienigma bulk ops used a permission map keyed'enigma2'while the type is'enigma'→ null permission → every enigma bulk op silently failed. Now resolvesedit_e2correctly.Verification
Every one of the 18 commits passes:
php -l,make gates(incl.check-procedural-use),make phpstan(0 errors),make cs.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.