diff --git a/core/lib/Drupal/Core/Messenger/MessengerInterface.php b/core/lib/Drupal/Core/Messenger/MessengerInterface.php index fcc5b55..bd0f705 100644 --- a/core/lib/Drupal/Core/Messenger/MessengerInterface.php +++ b/core/lib/Drupal/Core/Messenger/MessengerInterface.php @@ -3,27 +3,26 @@ namespace Drupal\Core\Messenger; /** - * Stores messages send out to the user on the page. + * Stores runtime messages sent out to individual users on the page. * - * Examples for these messages are for example that a specific content got - * saved. + * An example for these messages is for example: "Content X got saved". */ interface MessengerInterface { /** * A status message. */ - const STATUS = 'status'; + const TYPE_STATUS = 'status'; /** * A warning. */ - const WARNING = 'warning'; + const TYPE_WARNING = 'warning'; /** * An error. */ - const ERROR = 'error'; + const TYPE_ERROR = 'error'; /** * Adds a new message to the queue. @@ -33,22 +32,23 @@ * consistency with other messages, it should begin with a capital letter * and end with a period. * @param string $type - * (optional) The message's type. Either self::STATUS, self::WARNING, or - * self::ERROR. + * (optional) The message's type. Either self::TYPE_STATUS, + * self::TYPE_WARNING, or self::TYPE_ERROR. * @param bool $repeat * (optional) If this is FALSE and the message is already set, then the * message won't be repeated. Defaults to FALSE. * * @return $this */ - public function addMessage($message, $type = self::STATUS, $repeat = FALSE); + public function addMessage($message, $type = self::TYPE_STATUS, $repeat = FALSE); /** * Gets all messages. * * @return array[] * Keys are message types and values are indexed arrays of messages. Message - * types are either self::STATUS, self::WARNING, or self::ERROR. + * types are either self::TYPE_STATUS, self::TYPE_WARNING, or + * self::TYPE_ERROR. */ public function getMessages(); @@ -56,7 +56,8 @@ public function getMessages(); * Gets all messages of a certain type. * * @param string $type - * The messages' type. Either self::STATUS, self::WARNING, or self::ERROR. + * The messages' type. Either self::TYPE_STATUS, self::TYPE_WARNING, + * or self::TYPE_ERROR. * * @return string[] */ @@ -73,7 +74,8 @@ public function deleteMessages(); * Deletes all messages of a certain type. * * @param string $type - * The messages' type. Either self::STATUS, self::WARNING, or self::ERROR. + * The messages' type. Either self::TYPE_STATUS, self::TYPE_WARNING, or + * self::TYPE_ERROR. * * @return $this */ diff --git a/core/lib/Drupal/Core/Messenger/SessionMessenger.php b/core/lib/Drupal/Core/Messenger/SessionMessenger.php index e293fbd..fc858fd 100644 --- a/core/lib/Drupal/Core/Messenger/SessionMessenger.php +++ b/core/lib/Drupal/Core/Messenger/SessionMessenger.php @@ -8,9 +8,6 @@ /** * Provides a session-based messenger. - * - * This is the default implementation used by Drupal to store message to the - * user. */ class SessionMessenger implements MessengerInterface { @@ -35,7 +32,7 @@ public function __construct(KillSwitch $page_cache_kill_switch) { /** * {@inheritdoc} */ - public function addMessage($message, $type = self::STATUS, $repeat = FALSE) { + public function addMessage($message, $type = self::TYPE_STATUS, $repeat = FALSE) { if (!isset($_SESSION['messages'][$type])) { $_SESSION['messages'][$type] = []; } @@ -46,7 +43,7 @@ public function addMessage($message, $type = self::STATUS, $repeat = FALSE) { } // Do not use strict type checking so that equivalent string and - // MarkupInterface objects are detected. + // \Drupal\Core\Render\Markup objects are detected. if ($repeat || !in_array($message, $_SESSION['messages'][$type])) { $_SESSION['messages'][$type][] = $message; $this->pageCacheKillSwitch->trigger(); diff --git a/core/lib/Drupal/Core/Messenger/StaticMessenger.php b/core/lib/Drupal/Core/Messenger/StaticMessenger.php index 52f7dcb..f2e0f51 100644 --- a/core/lib/Drupal/Core/Messenger/StaticMessenger.php +++ b/core/lib/Drupal/Core/Messenger/StaticMessenger.php @@ -15,8 +15,8 @@ class StaticMessenger implements MessengerInterface { * The messages that have been set. * * @var array[] - * Keys are either self::STATUS, self::WARNING, or self::ERROR. Values are - * arrays of arrays with the following keys: + * Keys are either self::TYPE_STATUS, self::TYPE_WARNING, or + * self::TYPE_ERROR. Values are arrays of arrays with the following keys: * - message (string): the message. * - safe (bool): whether the message is marked as safe markup. */ @@ -42,7 +42,7 @@ public function __construct(KillSwitch $page_cache_kill_switch) { /** * {@inheritdoc} */ - public function addMessage($message, $type = self::STATUS, $repeat = FALSE) { + public function addMessage($message, $type = self::TYPE_STATUS, $repeat = FALSE) { if (!isset($this->messages[$type])) { $this->messages[$type] = []; }