Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use asModelFailure and asModelSuccess in v4 #85

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

bencroker
Copy link
Contributor

@bencroker bencroker commented Feb 9, 2024

This PR changes the return values of failure and success responses to use Craft’s asModelFailure and asModelSuccess controller methods. This helps standardise response structures and brings them in-line with how things have been done since Craft 4.

This introduces a breaking change for the return values of JSON responses (https://github.com/craftcms/guest-entries/blob/main/README.md#submitting-via-ajax), therefore it should be considered it for version 4 (with Craft 5 compatibility).

I’m specifically requesting this change to make it easier for Sprig v3 to handle responses from the SaveController, which otherwise have to be handled individually, due to this inconsistency:
https://github.com/putyourlightson/craft-sprig-core/blob/f7b60d416d935a4dd089a4b43d682087a79b991a/src/controllers/ComponentsController.php#L106-L108

@bencroker bencroker changed the title Use asModelFailure and asModelSuccess in v3 Use asModelFailure and asModelSuccess in v4 Feb 9, 2024
@brandonkelly brandonkelly changed the base branch from 3.x to 4.x March 19, 2024 22:35
@brandonkelly brandonkelly merged commit 01d1c07 into craftcms:4.x Mar 19, 2024
5 checks passed
@brandonkelly
Copy link
Member

Thanks! Just tagged version 4.0.0 with this change. That version is compatible with both Craft 4 and 5, so you may be able to resolve that awkwardness with Spring for Craft 4 as well.

@bencroker bencroker deleted the patch-2 branch April 2, 2024 13:28
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.

2 participants