Purpose
MHM Rentiva aims to delegate business logic to service classes in order to prevent the "Fat Controller" anti-pattern. This page is a technical audit report of the current controllers.
𧬠Controller and Service Layer Architecture
The plugin architecture is based on controllers only receiving requests, performing authorization checks, and delegating work to the relevant service classes.
ποΈ 1. Controller Design Patternsβ
All *Controller.php classes must follow these rules:
- Presentation-Only: Must not perform data calculations.
- Validation: Must validate request input data.
- Authorization: Must perform capability checks via
current_user_canorSecurityHelper.
π 2. AJAX Controllers Reportβ
A. AnalyticsController (Thin Controller)β
- File:
src/Core/Dashboard/AnalyticsController.php - Role: Handles statistics requests.
- Business Logic: Revenue, occupancy, and chart data are entirely within
AnalyticsService. - Result: β Compliant with standards.
B. PayoutAjaxController (Thin Controller)β
- File:
src/Core/Financial/PayoutAjaxController.php - Role: Initiates payout requests.
- Business Logic: The
PayoutServiceandAtomicPayoutService(Transaction) classes execute the operation. - Result: β Compliant with standards.
π 3. REST Controllers Reportβ
A. HealthController (Audit Status)β
- File:
src/Api/REST/HealthController.php - Observation: Some database health queries are located directly inside the controller.
- Recommendation: Migrating this logic to a
SystemHealthServiceclass is planned. - Result: β οΈ Improvement pending.
B. PayoutCallbackController (Transaction Controller)β
- File:
src/Api/REST/PayoutCallbackController.php - Role: Processes payment callbacks with their evidence.
- Security: HMAC signature verification is handled centrally via
AuthHelper. - Result: β Compliant with standards.
π οΈ 4. Architectural Standards and Recommendationsβ
The following methods are used to standardize error handling:
ErrorHandler::format_error(): All error responses are standardized through this method.- DTO Classes: When returning large JSON payloads, DTO classes are used instead of arrays to guarantee a data contract.
Sanitizer::*: All incoming variables are processed through the sanitization layer rather than as raw data.
Section Summaryβ
- Controllers are kept "Thin."
- Business logic is centralized in "Service" classes.
- API security is provided by
AuthHelperandSecurityHelper.
Changelogβ
| Date | Version | Note |
|---|---|---|
| 23.04.2026 | 4.27.2 | English translation added. |
| 19.03.2026 | 4.21.2 | Controller audit report and design patterns added. |