Skip to content

Renamed controller methods to Laravel resource naming and added new cart action URLs - #4385

Merged
lukeholder merged 1 commit into
6.xfrom
feature/com-689-controller-resource-naming
Oct 12, 2026
Merged

lukeholder merged 1 commit into
6.xfrom
feature/com-689-controller-resource-naming

Conversation

@lukeholder

Copy link
Copy Markdown
Member

Resolves COM-689 (sub-issue of COM-613).

What this does

Commerce's controllers in src/Http/Controllers used Yii-flavoured method names (save, delete, editStore, getCart). This renames them to the Laravel resource naming core already uses (index, create, store, edit, destroy), and adds new front-end cart URLs to match, keeping the 5.x cart URLs working with a deprecation.

Controller method renames

Method renames only. Routes map URL to method, so every existing URL is unchanged, including the 5.x action URLs such as commerce/discounts/save.

  • save() is now store() in 21 controllers, and delete() is now destroy() in 15. Core uses a single store() for both create and update, so there is no store/update split.
  • 19 controllers that served both the new and {id} routes from one edit() now have a create() and an edit(), both calling a shared private editScreen() (core's pattern). edit() now requires the id.
  • Redundant nouns are dropped: StoresController::storesIndex() is index(), ProductTypesController::saveProductType() is store(), OrdersController::editOrder() is edit(), and so on.
  • get… prefixes are dropped from JSON endpoints: CartController::getCart() is show(), OrdersController::getPaymentModal() is paymentModal(), and so on.
  • InventoryController is tidied: editLocationLevels() is index(), inventoryLevelsTableData() is tableData(), itemEdit()/itemSave() are editItem()/storeItem().
  • Three "create new" links (tax zone, tax category, inventory location) pointed at edit; they now point at create.

The full old-to-new table is in COM-689.

Left alone on purpose: archive() and deactivate() (they don't delete), StoresController::editSiteStores()/saveSiteStores() (a second resource in the same controller, which wants its own controller), and non-resource verbs such as reorder, renderUi and updateStatus.

Front-end cart URLs

New URL Deprecated URL (still works)
commerce/cart/show commerce/cart/get-cart
commerce/cart/update commerce/cart/update-cart
commerce/cart/load commerce/cart/load-cart
commerce/cart/forget commerce/cart/forget-cart
  • The deprecated URLs are routed to the same actions through a new LogDeprecatedAction route middleware, which logs to core's Deprecator so hits show in the Deprecation Warnings utility. They keep the same rate limiting.
  • Cart recovery links and the example templates now use the new URLs.
  • Recovery links issued for commerce/cart/load-cart still load the cart, through either URL.

Every 5.x site will log these deprecations until its templates are updated, since update-cart is in nearly every cart form.

Testing

  • New CartDeprecatedActionsTest: each deprecated URL responds the same as its replacement and logs exactly one deprecation, and a recovery link issued for the deprecated load-cart action still loads the cart.
  • Existing cart tests now use the new URLs.
  • Before rebasing onto the latest 6.x: PHPStan and check-cs clean, full Pest suite passing (819 tests).
  • After rebasing: PHPStan reports 4 errors and 4 controller tests fail locally, all in the Purchasable*Field classes changed by 49c7ede, which call Group::showStatus(). That needs the cms commit the lock now pins (0cbc515d15c); my local cms checkout is 7 commits behind it. None of the affected files are touched by this PR.

🤖 Generated with Claude Code

@lukeholder
lukeholder requested a review from a team as a code owner October 12, 2026 10:43
@linear-code

linear-code Bot commented Oct 12, 2026

Copy link
Copy Markdown

COM-689

@lukeholder
lukeholder merged commit 3cc7144 into 6.x Oct 12, 2026
6 checks passed
@lukeholder
lukeholder deleted the feature/com-689-controller-resource-naming branch October 12, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant