Skip to content

replace controller logic with dedicated handler and service classes (CQRS-Lite)#91

Open
solverat wants to merge 42 commits into
1.xfrom
controller-to-services
Open

replace controller logic with dedicated handler and service classes (CQRS-Lite)#91
solverat wants to merge 42 commits into
1.xfrom
controller-to-services

Conversation

@solverat

@solverat solverat commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Extracts all business logic from admin controllers into dedicated handler, service, and enricher classes.
Controllers are now thin dispatch layers: they receive a typed Payload, pass it to a Handler, and return the result. Request parsing no longer happens inside controllers or handlers.

Changes 🤯

Handlers & Payloads

Every controller action now has a corresponding Handler (invokable) and a Payload implementing ExtJsPayloadInterface.
The payload is resolved from the request by a new ExtJsValueResolver, keeping Request out of handlers entirely.

Common payload shapes (IdQueryPayload, IdBodyPayload, EmptyPayload, etc.) live in src/Payload/Common/.

File uploads (add-asset, add-asset-compatibility, upload-custom-logo, replace-asset) are covered too, multipart and base64 alike.

Services

Business logic shared across handlers was extracted into service classes under src/Service/:

  • Document/DocumentPayloadMapper, DocumentPersistenceCoordinator
  • Asset/AssetPayloadMapper, AssetUploadService
  • DataObject/DataObjectPayloadMapper
  • Grid/GridColumnConfigService, GridBatchService, GridExportService
  • Element/EditLockService, Element/SessionService
  • Login/LoginPageService
  • Portal/DashboardService
  • Admin/AdminSettingsService, AdminStatisticsService
  • Notification/NotificationFilterParser
  • Workflow/WorkflowElementResolver
  • Translation/AdminSearchTermResolver

Repository

Persistence-only classes under src/Repository/:

  • DashboardRepository

Enrichers

Post-processing of element data was split into enrichers under src/Enricher/:

  • Element/AdminStyleEnricher, Element/UserNamesEnricher
  • Document/DocumentMetaEnricher, DraftEnricher, PropertiesEnricher, TranslationEnricher
  • DataObject/DraftEnricher, CustomLayoutEnricher

Permissions

Access control moved from manual checkPermission() calls inside controller methods to #[IsGranted] attributes on actions, backed by PermissionVoter.

HTTP layer

  • ExtJsValueResolver resolves Payload objects from the request via fromRequest()
  • ApiResponse DTO for consistent JSON response shape
  • AdminExceptionListener centralizes exception-to-response mapping, including ElementLockedException (editlock dialog) and AdminOperationFailedException (recoverable business-rule failures), instead of per-controller try/catch

ExtJS xaction dispatching

ExtJS CRUD endpoints that send a single URL with an xaction parameter (create, update, destroy) are now handled via $this->forward() to dedicated per-action methods.
Each target action has its own typed Payload, Handler, and #[IsGranted] attribute instead of a branching switch statement inside one fat action.

Removed

  • src/Controller/Traits/ApplySchedulerDataTrait, UserNameTrait
  • src/EventListener/Traits/ControllerTypeTrait

@solverat
solverat requested a review from benwalch June 18, 2026 14:44
@solverat solverat added the enhancement New feature or request label Jun 18, 2026
@solverat solverat changed the title replace controller logic with dedicated handler and service classes (CQRS-Lite)Controller to services replace controller logic with dedicated handler and service classes (CQRS-Lite) Jun 18, 2026
@solverat
solverat removed the request for review from benwalch June 18, 2026 14:45
@solverat solverat self-assigned this Jun 18, 2026
@solverat solverat added this to the 1.4.0 milestone Jun 30, 2026
@solverat
solverat force-pushed the controller-to-services branch from 26c7f18 to 8d55228 Compare July 10, 2026 09:10
solverat added 9 commits July 10, 2026 15:22
…ler and payload for improved filter handling
…ss controllers, centralize edit lock logic in AdminExceptionListener
…nFailedException, referencing AdminExceptionListener for improved clarity
…pository, and dependencies for improved dashboard management
…tisticsService, refactor handlers and dependencies for improved maintainability
…resolvers, and controllers for improved consistency and maintainability
…ails for AdminOperationFailedException and ElementLockedException
…oad and custom logo upload, refactor related handlers and controllers for improved maintainability
solverat added 10 commits July 10, 2026 18:17
…for improved data robustness and error prevention
… rely on shared ResultInterface for consistency and maintainability
…teway implementations for improved session handling and maintainability
…ceData` classes, improve consistency and simplify result handling
… comment in UserProfileController, and simplify path handling in GetIdPathPagingInfoHandler
Ports the 6 upstream 1.x commits: null/false guards for read/get
operations (GDPR export, icon inline helper), Content-Disposition
header fix (already present here independently), quantity-value
xaction JSON validation, and TranslationController variable/security
updates.

Controller-level conflicts (Asset/Class/QuantityValue/Translation)
resolved in favor of this branch's already-refactored Handler-based
implementations; the underlying fixes from the old monolithic bodies
were ported manually into their new homes:
- TranslationQueryTrait::getGridFilterCondition() now whitelists
  allowed non-language filter/sort fields
- DashboardRepository::load() hardens unserialize() with
  allowed_classes: false
- GetClassIconsHandler skips unreadable icon files instead of
  emitting a broken image tag
- QuantityValueUnitPayload validates decoded JSON is an array

Helper/Dashboard.php stays deleted (superseded by DashboardRepository).
@solverat
solverat force-pushed the controller-to-services branch from 6e5f590 to 147f685 Compare July 15, 2026 10:33
@solverat
solverat marked this pull request as ready for review July 16, 2026 10:33
@solverat
solverat requested review from benwalch and scrummer July 16, 2026 10:33
solverat added 7 commits July 16, 2026 14:13
…s and result classes; remove obsolete payloads and unused handler implementations.
…ation to DTO methods; simplify service and handler logic.
…solver`, introduce dedicated handlers for fileinfo and resolution, and simplify controller and service dependencies.
…PreSendDataEventEnricher`, remove redundant event dispatching, and simplify handler outcomes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant