@@ -188,8 +188,8 @@ For more information, see the :doc:`Routing chapter </routing>`.
188
188
189
189
.. caution ::
190
190
191
- The ``redirect() `` method does not check its destination in any way. If you
192
- redirect to some URL provided by the end-users, your application may be open
191
+ The ``redirect() `` method does not check its destination in any way. If you
192
+ redirect to some URL provided by the end-users, your application may be open
193
193
to the `unvalidated redirects security vulnerability `_.
194
194
195
195
@@ -425,21 +425,43 @@ read any flash messages from the session:
425
425
.. code-block :: html+twig
426
426
427
427
{# app/Resources/views/base.html.twig #}
428
- {% for flash_message in app.session.flashBag.get('notice') %}
428
+
429
+ {# you can read and display just one flash message type... #}
430
+ {% for flash_message in app.session.flash('notice') %}
429
431
<div class="flash-notice">
430
432
{{ flash_message }}
431
433
</div>
432
434
{% endfor %}
433
435
436
+ {# ...or you can read and display every flash message available #}
437
+ {% for type, flash_messages in app.session.flashes %}
438
+ {% for flash_message in flash_messages %}
439
+ <div class="flash-{{ type }}">
440
+ {{ flash_message }}
441
+ </div>
442
+ {% endif %}
443
+ {% endfor %}
444
+
434
445
.. code-block :: html+php
435
446
436
447
<!-- app/Resources/views/base.html.php -->
448
+
449
+ // you can read and display just one flash message type...
437
450
<?php foreach ($view['session']->getFlash('notice') as $message): ?>
438
451
<div class="flash-notice">
439
- <?php echo "<div class='flash-error'> $message</div>" ?>
452
+ <?php echo $message ?>
440
453
</div>
441
454
<?php endforeach ?>
442
455
456
+ // ...or you can read and display every flash message available
457
+ <?php foreach ($view['session']->getFlashes() as $type => $flash_messages): ?>
458
+ <?php foreach ($flash_messages as $flash_message): ?>
459
+ <div class="flash-<?php echo $type ?>">
460
+ <?php echo $message ?>
461
+ </div>
462
+ <?php endforeach ?>
463
+ <?php endforeach ?>
464
+
443
465
.. note ::
444
466
445
467
It's common to use ``notice ``, ``warning `` and ``error `` as the keys of the
0 commit comments