-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add support for statement messages in FlashMessenger class #19169
Add support for statement messages in FlashMessenger class #19169
Conversation
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This class handles the flash messages instead of being a collection of flash messages, so FlashMessenger is a better name. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
src/FlashMessenger.php
Outdated
|
||
/** @var mixed[] */ | ||
private array $storage; | ||
|
||
/** @var array<string, string[]> */ | ||
/** @psalm-var list<array{context: string, message: string, statement: string}> */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's anything Psalm-specific here anymore. Both list and array shape are universally supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think sudo-bot/action-doctum does not support this format yet. Am I right, @williamdes?
src/Twig/MessageExtension.php
Outdated
/** @inheritDoc */ | ||
public function getFunctions(): array | ||
{ | ||
return [new TwigFunction('statement_message', Generator::getMessage(...), ['is_safe' => ['html']])]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That match
statement would fit here more than inside the function. You can do an anonymous function and as a default throw an exception so that we avoid typos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will left MessageType::Notice
as default for now, as I think Generator::getMessage()
should be refactored to extract all the HTML from it, and maybe a view helper for MessageType
to match with the Bootstrap classes.
Does not group the messages by context. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
90514b9
to
d17e46c
Compare
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Besides standard feedback messages, is also common to have a feedback message with the executed statement after an action is executed. This allows to use HTTP redirection in those cases.