← ClaudeAtlas

implement-cqrs-handlerslisted

Implement all command and query handlers in the Adapter layer. Each handler delegates to the repository for persistence — no direct SQL or ObjectModel access. Handlers use #[AsCommandHandler] / #[AsQueryHandler] attributes for auto-registration. Trigger: "implement handlers for {Domain}".
jeffsenso/prestashop-skills · ★ 4 · AI & Automation · score 79
Install: claude install-skill jeffsenso/prestashop-skills
# implement-cqrs-handlers Handlers live in `src/Adapter/{Domain}/CommandHandler/` and `QueryHandler/`. See [CQRS/CONTEXT.md](../../CONTEXT.md#handlers) for conventions (`#[AsCommandHandler]`/`#[AsQueryHandler]` attributes, no cross-handler calls, return types). ## 1. Add handler `Add{Domain}Handler.php` implementing `Add{Domain}HandlerInterface`: - Inject `{Domain}Repository` - `handle(Add{Domain}Command $command): {Domain}Id`: - Construct the ObjectModel entity from command data - For multilingual fields, map `$command->getLocalizedNames()` to the lang array - Call `$this->repository->create(...)` - Return the new `{Domain}Id` - Catch persistence exceptions, rethrow as domain exceptions **Reference:** `src/Adapter/Tax/CommandHandler/AddTaxHandler.php` (simple), `src/Adapter/Manufacturer/CommandHandler/AddManufacturerHandler.php` (with image) ## 2. Edit handler (partial-update) `Edit{Domain}Handler.php` implementing `Edit{Domain}HandlerInterface`: - Load entity: `$entity = $this->repository->get{Domain}($command->getId())` - For each field: `if ($command->getName() !== null) { $entity->name = $command->getName(); }` - Apply only non-null fields — never overwrite with null - Call `$this->repository->update($entity)` - Sub-resource commands are dispatched independently, not composed here **Reference:** `src/Adapter/Tax/CommandHandler/EditTaxHandler.php` (simple), `src/Adapter/Carrier/CommandHandler/EditCarrierHandler.php` (many fields) ## 3. Delete handler `D