summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core/Render
diff options
context:
space:
mode:
authorAlex Pott2018-05-07 10:08:12 (GMT)
committerAlex Pott2018-05-07 10:08:12 (GMT)
commit3c82d71d7be95cb0a0c4e6f926a8516e1466fa2f (patch)
tree533bac4f0e0e826b73a34339ca2a94c0f83fe2b9 /core/lib/Drupal/Core/Render
parent07df22824734b5b78aa3465ce4d6e18379ded9b3 (diff)
Issue #2935255 by Jo Fitzgerald, kim.pepper, voleger, alexpott, martin107, jibran, catch: Remove all usages of drupal_get_message and drupal_set_message in core lib
Diffstat (limited to 'core/lib/Drupal/Core/Render')
-rw-r--r--core/lib/Drupal/Core/Render/Element/StatusMessages.php15
-rw-r--r--core/lib/Drupal/Core/Render/Renderer.php4
2 files changed, 13 insertions, 6 deletions
diff --git a/core/lib/Drupal/Core/Render/Element/StatusMessages.php b/core/lib/Drupal/Core/Render/Element/StatusMessages.php
index 530457f..578d28f 100644
--- a/core/lib/Drupal/Core/Render/Element/StatusMessages.php
+++ b/core/lib/Drupal/Core/Render/Element/StatusMessages.php
@@ -5,7 +5,7 @@ namespace Drupal\Core\Render\Element;
/**
* Provides a messages element.
*
- * Used to display results of drupal_set_message() calls.
+ * Used to display results of \Drupal::messenger()->addMessage() calls.
*
* Usage example:
* @code
@@ -61,7 +61,8 @@ class StatusMessages extends RenderElement {
*
* @param string|null $type
* Limit the messages returned by type. Defaults to NULL, meaning all types.
- * Passed on to drupal_get_messages(). These values are supported:
+ * Passed on to \Drupal\Core\Messenger\Messenger::deleteByType(). These
+ * values are supported:
* - NULL
* - 'status'
* - 'warning'
@@ -72,9 +73,15 @@ class StatusMessages extends RenderElement {
*
* @see drupal_get_messages()
*/
- public static function renderMessages($type) {
+ public static function renderMessages($type = NULL) {
$render = [];
- $messages = drupal_get_messages($type);
+ if (isset($type)) {
+ $messages = \Drupal::messenger()->deleteByType($type);
+ }
+ else {
+ $messages = \Drupal::messenger()->deleteAll();
+ }
+
if ($messages) {
// Render the messages.
$render = [
diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php
index d435798..bae83de 100644
--- a/core/lib/Drupal/Core/Render/Renderer.php
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -649,8 +649,8 @@ class Renderer implements RendererInterface {
// being rendered: any code can add messages to render.
// This violates the principle that each lazy builder must be able to render
// itself in isolation, and therefore in any order. However, we cannot
- // change the way drupal_set_message() works in the Drupal 8 cycle. So we
- // have to accommodate its special needs.
+ // change the way \Drupal\Core\Messenger\Messenger works in the Drupal 8
+ // cycle. So we have to accommodate its special needs.
// Allowing placeholders to be rendered in a particular order (in this case:
// last) would violate this isolation principle. Thus a monopoly is granted
// to this one special case, with this hard-coded solution.