-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
SUMMARY
The plugin logic is currently concentrated in massive, monolithic procedural files like functions.php (2,500+ lines) and setup.php. These files mix UI rendering, business logic, and database access, making maintenance difficult and testing nearly impossible without complex stubs.
Existing structure:
functions.php: Contains poller logic, HTML generation, and database wrappers.setup.php: Handles installation, upgrades, and hook registration.
WHY REFACTOR
The monolithic approach leads to high cognitive load and increased risk of regression during updates. Separating concerns into distinct layers (Models, Services, Views) will allow for better code reuse, easier unit testing, and a cleaner path for future modernization (e.g., Cacti 1.3+ support).
PROPOSED CHANGE
Transition to a modern, object-oriented architecture under the src/ directory:
- Models: Introduce entity classes (e.g.,
Cacti\Syslog\Models\Alert) to handle data structure and basic persistence. - Services: Move complex business logic into specialized service classes (e.g.,
Cacti\Syslog\Services\RemovalProcessor). - Autoloading: Fully utilize PSR-4 via the existing
composer.jsonconfiguration.
SCOPE
- Creation of
src/Modelsandsrc/Servicesdirectories. - Incremental extraction of logic from
functions.php. - No functional changes to the plugin behavior; strictly architectural.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels