Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita103278

Browse files
committed
Merge pull requestsymfony#2631 from symfony/session-flash-revert
Revert "fixed example to check if the session exists when getting flash ...
2 parents8aee1ab +ac6d9f3 commita103278

File tree

3 files changed

+13
-32
lines changed

3 files changed

+13
-32
lines changed

‎book/controller.rst‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -686,23 +686,19 @@ the ``notice`` message:
686686

687687
..code-block::html+jinja
688688

689-
{% if app.session.started %}
690-
{% for flashMessage in app.session.flashbag.get('notice') %}
691-
<div class="flash-notice">
692-
{{ flashMessage }}
693-
</div>
694-
{% endfor %}
695-
{% endif %}
689+
{% for flashMessage in app.session.flashbag.get('notice') %}
690+
<div class="flash-notice">
691+
{{ flashMessage }}
692+
</div>
693+
{% endfor %}
696694

697695
..code-block::html+php
698696

699-
<?php if ($view['session']->isStarted()): ?>
700-
<?php foreach ($view['session']->getFlashBag()->get('notice') as $message): ?>
701-
<div class="flash-notice">
702-
<?php echo "<div class='flash-error'>$message</div>" ?>
703-
</div>
704-
<?php endforeach; ?>
705-
<?php endif; ?>
697+
<?php foreach ($view['session']->getFlashBag()->get('notice') as $message): ?>
698+
<div class="flash-notice">
699+
<?php echo "<div class='flash-error'>$message</div>" ?>
700+
</div>
701+
<?php endforeach; ?>
706702

707703
By design, flash messages are meant to live for exactly one request (they're
708704
"gone in a flash"). They're designed to be used across redirects exactly as

‎components/http_foundation/sessions.rst‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,3 @@ Compact method to process display all flashes at once::
333333
echo "<div class='flash-$type'>$message</div>\n";
334334
}
335335
}
336-
337-
..caution::
338-
339-
As flash messages use a session to store the messages from one request to
340-
the next one, a session will be automatically started when you read the
341-
flash messages even if none already exists. To avoid that default
342-
behavior, test if there is an existing session first::
343-
344-
if ($session->isStarted()) {
345-
foreach ($session->getFlashBag()->get('warning', array()) as $message) {
346-
echo "<div class='flash-warning'>$message</div>";
347-
}
348-
}

‎quick_tour/the_controller.rst‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,9 @@ next request::
141141

142142
// display any messages back in the next request (in a template)
143143

144-
{% if app.session.started %}
145-
{% for flashMessage in app.session.flashbag.get('notice') %}
146-
<div>{{ flashMessage }}</div>
147-
{% endfor %}
148-
{% endif %}
144+
{% for flashMessage in app.session.flashbag.get('notice') %}
145+
<div>{{ flashMessage }}</div>
146+
{% endfor %}
149147

150148
This is useful when you need to set a success message before redirecting
151149
the user to another page (which will then show the message). Please note that

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp