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

Support custom ModelManagerException messages #8141

Conversation

wadjei
Copy link
Contributor

@wadjei wadjei commented Dec 13, 2023

Support custom ModelManagerException messages

Add the option of customising the message passed to the FlashBag for caught ModelManagerException by returning a
string from your overridden handleModelManagerException() methods.

This is similar to what was done previously for handleModelManagerThrowable() but that code path seems to
be unreachable.

The method signature for handleModelManagerException has had its return type removed.

New tests have been added to validate the changes work as intended by way of two new controllers in the Sonata\AdminBundle\Tests\App\Controller namespace: CustomModelManagerThrowableMessageController and CustomModelManagerExceptionMessageController.

I am targeting this branch, because the change addresses an apparent inability to use handleModelManagerThrowable customised message facility from #7761.

Closes #8137

Changelog

### Changed
CRUDController::handleModelManagerException can now return a custom error message string for display in the flashbag instead of Sonata ones. Return type is removed from the signature

@VincentLanglet
Copy link
Member

Thanks ; can you take a look at the failing build ?

Copy link
Member

@VincentLanglet VincentLanglet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to run make cs-fix-php

phpunit.xml.dist Outdated Show resolved Hide resolved
src/Controller/CRUDController.php Outdated Show resolved Hide resolved
@VincentLanglet VincentLanglet merged commit 8b47fe7 into sonata-project:4.x Dec 19, 2023
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Customise error message for ModelManagerException
2 participants