Repository navigation
Renamed controller methods to Laravel resource naming and added new cart action URLs - #4385
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves COM-689 (sub-issue of COM-613).
What this does
Commerce's controllers in
src/Http/Controllersused 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 nowstore()in 21 controllers, anddelete()is nowdestroy()in 15. Core uses a singlestore()for both create and update, so there is nostore/updatesplit.newand{id}routes from oneedit()now have acreate()and anedit(), both calling a shared privateeditScreen()(core's pattern).edit()now requires the id.StoresController::storesIndex()isindex(),ProductTypesController::saveProductType()isstore(),OrdersController::editOrder()isedit(), and so on.get…prefixes are dropped from JSON endpoints:CartController::getCart()isshow(),OrdersController::getPaymentModal()ispaymentModal(), and so on.InventoryControlleris tidied:editLocationLevels()isindex(),inventoryLevelsTableData()istableData(),itemEdit()/itemSave()areeditItem()/storeItem().edit; they now point atcreate.The full old-to-new table is in COM-689.
Left alone on purpose:
archive()anddeactivate()(they don't delete),StoresController::editSiteStores()/saveSiteStores()(a second resource in the same controller, which wants its own controller), and non-resource verbs such asreorder,renderUiandupdateStatus.Front-end cart URLs
commerce/cart/showcommerce/cart/get-cartcommerce/cart/updatecommerce/cart/update-cartcommerce/cart/loadcommerce/cart/load-cartcommerce/cart/forgetcommerce/cart/forget-cartLogDeprecatedActionroute middleware, which logs to core'sDeprecatorso hits show in the Deprecation Warnings utility. They keep the same rate limiting.commerce/cart/load-cartstill load the cart, through either URL.Every 5.x site will log these deprecations until its templates are updated, since
update-cartis in nearly every cart form.Testing
CartDeprecatedActionsTest: each deprecated URL responds the same as its replacement and logs exactly one deprecation, and a recovery link issued for the deprecatedload-cartaction still loads the cart.6.x: PHPStan andcheck-csclean, full Pest suite passing (819 tests).Purchasable*Fieldclasses changed by 49c7ede, which callGroup::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