Add root category and position endpoints to the Category domain#325
Add root category and position endpoints to the Category domain#325mattgoud wants to merge 4 commits into
Conversation
Expose three missing Category CQRS operations:
- AddRootCategoryCommand -> POST /categories/root
- EditRootCategoryCommand -> PATCH /categories/root/{categoryId}
- UpdateCategoryPositionCommand -> PUT /categories/{categoryId}/position
The root add/edit operations reuse the Category resource (same output query
and fields) with dedicated command mappings, since AddRootCategoryCommand takes
name/linkRewrite constructor arguments and has no parent category. The position
operation is a no-output action returning 204. Covers all three with integration
tests.
…covered by core Behat)
/categories/roots, /categories/roots/{categoryId} and
/categories/{categoryId}/positions (matching the module's plural-segment convention).
📋 Summary of changesThis PR exposes three previously missing Category CQRS operations in the Admin API: ⏱️ Estimated review time8–12 minutes — three new operations, one new resource file, and several new test methods to read through; no architectural novelty but some CQRS mapping subtleties to verify against Core commands. 🎯 Scope
🧱 API Platform / CQRS architecture complianceRoot-category operations (
|
… docs - testAddRootCategory now asserts the enabled field - add testInvalidUpdateCategoryPosition covering the CategoryException => 422 path - clarify the positions entry-prefix docblock and the enabled->isActive mapping
|
Thanks for the review. Triage of the points: Applied (e43bdf3):
Verified, not a bug — Not applied, with reasons:
|
AddRootCategoryCommand(POST /categories/roots),EditRootCategoryCommand(PATCH /categories/roots/{categoryId}) andUpdateCategoryPositionCommand(PUT /categories/{categoryId}/positions), all under thecategory_writescope.CategoryEndpointTest.testAddRootCategory/testEditRootCategorycreate and edit a root category via/categories/roots;testEditUnknownRootCategoryReturnsNotFoundasserts the 404 mapping;testUpdateCategoryPositionreorders sibling categories via/categories/{categoryId}/positions.Notes:
Categoryresource (sameGetCategoryForEditingoutput and field set) with dedicated command mappings, becauseAddRootCategoryCommandtakesname/linkRewriteconstructor arguments and has no parent category (unlikeAddCategoryCommand).CQRSUpdateaction (read: false,output: false→ 204). Categories have no grid position definition (they use a tree), so the rawUpdateCategoryPositionCommandfields (parentCategoryId,way,positions,foundFirst) are exposed directly, matching the legacyupdatePositionAction. The reordering behaviour itself is covered by the core Behat scenarios incategory_management.feature.PUT /categories/{categoryId}/positionsendpoint (same command/scope/resource) and is a duplicate of this PR's position operation; it should be closed in favour of this one.