summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core/Render
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-05-15 14:50:54 (GMT)
committerNathaniel Catchpole2017-05-15 14:50:54 (GMT)
commit6b489d5d3e70282cab8154948e03dc8ba811aeec (patch)
tree8721dd2c5f7c71ba499ae55a5a5c127183fb2869 /core/lib/Drupal/Core/Render
parent12ac3a61a2dadec35d4162c44e004e93f27e7414 (diff)
Issue #2853509 by alexpott, xjm, nod_, dmsmidt, dawehner, catch, graber: Don't render status messages if there are no messages but also include their assets if there might be
Diffstat (limited to 'core/lib/Drupal/Core/Render')
-rw-r--r--core/lib/Drupal/Core/Render/Element/StatusMessages.php27
1 files changed, 16 insertions, 11 deletions
diff --git a/core/lib/Drupal/Core/Render/Element/StatusMessages.php b/core/lib/Drupal/Core/Render/Element/StatusMessages.php
index d16c245..530457f 100644
--- a/core/lib/Drupal/Core/Render/Element/StatusMessages.php
+++ b/core/lib/Drupal/Core/Render/Element/StatusMessages.php
@@ -73,17 +73,22 @@ class StatusMessages extends RenderElement {
* @see drupal_get_messages()
*/
public static function renderMessages($type) {
- // Render the messages.
- return [
- '#theme' => 'status_messages',
- // @todo Improve when https://www.drupal.org/node/2278383 lands.
- '#message_list' => drupal_get_messages($type),
- '#status_headings' => [
- 'status' => t('Status message'),
- 'error' => t('Error message'),
- 'warning' => t('Warning message'),
- ],
- ];
+ $render = [];
+ $messages = drupal_get_messages($type);
+ if ($messages) {
+ // Render the messages.
+ $render = [
+ '#theme' => 'status_messages',
+ // @todo Improve when https://www.drupal.org/node/2278383 lands.
+ '#message_list' => $messages,
+ '#status_headings' => [
+ 'status' => t('Status message'),
+ 'error' => t('Error message'),
+ 'warning' => t('Warning message'),
+ ],
+ ];
+ }
+ return $render;
}
}