You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The FlashBag allows us to peek() for a SINGLE type of message, or for ALL messages, but it would be useful to peek for multiple specific types.
My use case is to check whether or not there are any messages before outputting a wrapper HTML element.
I considered extending the existing peekAll() method to take an optional argument, but a dedicated method feels "more correct".
If this sounds like a useful feature I can supply a PR.
Example
Before:
{% ifapp.session.flashbag.peek('error') is notemptyorapp.session.flashbag.peek('warning') is notemptyorapp.session.flashbag.peek('notice') is notemptyorapp.session.flashbag.peek('foo') is notemptyorapp.session.flashbag.peek('bar') is notemptyorapp.session.flashbag.peek('baz') is notempty %}
<divclass="messages-wrapper">
{# show the messages #}
</div>
{% endif %}
After:
{% if app.session.flashbag.peekMultiple(['error','warning','notice','foo','bar','baz']) is not empty %}
<div class="messages-wrapper">
{# show the messages #}
</div>
{% endif %}
Note that I would prefer to pass a variable number of string arguments to peekMultiple() rather than an array, but I can't see how that would work in conjunction with allowing a final $default argument, as the current peek() method does.
The text was updated successfully, but these errors were encountered:
Description
The FlashBag allows us to
peek()
for a SINGLE type of message, or for ALL messages, but it would be useful to peek for multiple specific types.My use case is to check whether or not there are any messages before outputting a wrapper HTML element.
I considered extending the existing
peekAll()
method to take an optional argument, but a dedicated method feels "more correct".If this sounds like a useful feature I can supply a PR.
Example
Before:
After:
Note that I would prefer to pass a variable number of string arguments to peekMultiple() rather than an array, but I can't see how that would work in conjunction with allowing a final
$default
argument, as the currentpeek()
method does.The text was updated successfully, but these errors were encountered: