Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ae76f1

Browse files
author
Drak
committed
[HttpFoundation] Update documentation.
1 parent 910b5c7 commit 5ae76f1

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

CHANGELOG-2.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
304304
attributes storage behaviour from 2.0.x (default).
305305
* Added `Symfony\Component\HttpFoundation\Attribute\NamespacedAttributeBag` for
306306
namespace session attributes.
307+
* Flash API can stores messages in an array so there may be multiple messages
308+
per flash type. The old `Session` class API remains without BC break as it
309+
will single messages as before.
307310

308311
### HttpKernel
309312

UPGRADE-2.1.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,30 +307,31 @@ UPGRADE FROM 2.0 to 2.1
307307
Before:
308308
309309
```
310-
{% if app.session.hasFlash('notice') %}
310+
{% if app.session.flashbag.has('notice') %}
311311
<div class="flash-notice">
312-
{{ app.session.flash('notice') }}
312+
{{ app.session.flashbag.get('notice') }}
313313
</div>
314314
{% endif %}
315315
```
316-
317316
After:
318317
319318
```
320-
{% if app.session.flashbag.has('notice') %}
319+
{% for flashMessage in app.session.flashbag.get('notice') %}
321320
<div class="flash-notice">
322-
{{ app.session.flashbag.get('notice') }}
321+
{{ flashMessage }}
323322
</div>
324-
{% endif %}
323+
{% endfor %}
325324
```
326325
327326
You can process all flash messges in a single loop with:
328327
329328
```
330-
{% for type, flashMessage in app.session.flashbag.all() %}
331-
<div class="flash-{{ type }}">
332-
{{ flashMessage }}
333-
</div>
329+
{% for type, flashMessages in app.session.flashbag.all() %}
330+
{% for flashMessage in flashMessages) %}
331+
<div class="flash-{{ type }}">
332+
{{ flashMessage }}
333+
</div>
334+
{% endfor %}
334335
{% endfor %}
335336
```
336337

0 commit comments

Comments
 (0)