annotate core/lib/Drupal/Core/Messenger/MessengerInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 1fec387a4317
children
rev   line source
Chris@14 1 <?php
Chris@14 2
Chris@14 3 namespace Drupal\Core\Messenger;
Chris@14 4
Chris@14 5 /**
Chris@14 6 * Stores runtime messages sent out to individual users on the page.
Chris@14 7 *
Chris@14 8 * An example for these messages is for example: "Content X got saved".
Chris@14 9 */
Chris@14 10 interface MessengerInterface {
Chris@14 11
Chris@14 12 /**
Chris@14 13 * A status message.
Chris@14 14 */
Chris@14 15 const TYPE_STATUS = 'status';
Chris@14 16
Chris@14 17 /**
Chris@14 18 * A warning.
Chris@14 19 */
Chris@14 20 const TYPE_WARNING = 'warning';
Chris@14 21
Chris@14 22 /**
Chris@14 23 * An error.
Chris@14 24 */
Chris@14 25 const TYPE_ERROR = 'error';
Chris@14 26
Chris@14 27 /**
Chris@14 28 * Adds a new message to the queue.
Chris@14 29 *
Chris@14 30 * The messages will be displayed in the order they got added later.
Chris@14 31 *
Chris@14 32 * @param string|\Drupal\Component\Render\MarkupInterface $message
Chris@14 33 * (optional) The translated message to be displayed to the user. For
Chris@14 34 * consistency with other messages, it should begin with a capital letter
Chris@14 35 * and end with a period.
Chris@14 36 * @param string $type
Chris@14 37 * (optional) The message's type. Either self::TYPE_STATUS,
Chris@14 38 * self::TYPE_WARNING, or self::TYPE_ERROR.
Chris@14 39 * @param bool $repeat
Chris@14 40 * (optional) If this is FALSE and the message is already set, then the
Chris@14 41 * message won't be repeated. Defaults to FALSE.
Chris@14 42 *
Chris@14 43 * @return $this
Chris@14 44 */
Chris@14 45 public function addMessage($message, $type = self::TYPE_STATUS, $repeat = FALSE);
Chris@14 46
Chris@14 47 /**
Chris@14 48 * Adds a new status message to the queue.
Chris@14 49 *
Chris@14 50 * @param string|\Drupal\Component\Render\MarkupInterface $message
Chris@14 51 * (optional) The translated message to be displayed to the user. For
Chris@14 52 * consistency with other messages, it should begin with a capital letter
Chris@14 53 * and end with a period.
Chris@14 54 * @param bool $repeat
Chris@14 55 * (optional) If this is FALSE and the message is already set, then the
Chris@14 56 * message won't be repeated. Defaults to FALSE.
Chris@14 57 *
Chris@14 58 * @return $this
Chris@14 59 */
Chris@14 60 public function addStatus($message, $repeat = FALSE);
Chris@14 61
Chris@14 62 /**
Chris@14 63 * Adds a new error message to the queue.
Chris@14 64 *
Chris@14 65 * @param string|\Drupal\Component\Render\MarkupInterface $message
Chris@14 66 * (optional) The translated message to be displayed to the user. For
Chris@14 67 * consistency with other messages, it should begin with a capital letter
Chris@14 68 * and end with a period.
Chris@14 69 * @param bool $repeat
Chris@14 70 * (optional) If this is FALSE and the message is already set, then the
Chris@14 71 * message won't be repeated. Defaults to FALSE.
Chris@14 72 *
Chris@14 73 * @return $this
Chris@14 74 */
Chris@14 75 public function addError($message, $repeat = FALSE);
Chris@14 76
Chris@14 77 /**
Chris@14 78 * Adds a new warning message to the queue.
Chris@14 79 *
Chris@14 80 * @param string|\Drupal\Component\Render\MarkupInterface $message
Chris@14 81 * (optional) The translated message to be displayed to the user. For
Chris@14 82 * consistency with other messages, it should begin with a capital letter
Chris@14 83 * and end with a period.
Chris@14 84 * @param bool $repeat
Chris@14 85 * (optional) If this is FALSE and the message is already set, then the
Chris@14 86 * message won't be repeated. Defaults to FALSE.
Chris@14 87 *
Chris@14 88 * @return $this
Chris@14 89 */
Chris@14 90 public function addWarning($message, $repeat = FALSE);
Chris@14 91
Chris@14 92 /**
Chris@14 93 * Gets all messages.
Chris@14 94 *
Chris@14 95 * @return string[][]|\Drupal\Component\Render\MarkupInterface[][]
Chris@14 96 * Keys are message types and values are indexed arrays of messages. Message
Chris@14 97 * types are either self::TYPE_STATUS, self::TYPE_WARNING, or
Chris@14 98 * self::TYPE_ERROR.
Chris@14 99 */
Chris@14 100 public function all();
Chris@14 101
Chris@14 102 /**
Chris@14 103 * Gets all messages of a certain type.
Chris@14 104 *
Chris@14 105 * @param string $type
Chris@14 106 * The messages' type. Either self::TYPE_STATUS, self::TYPE_WARNING,
Chris@14 107 * or self::TYPE_ERROR.
Chris@14 108 *
Chris@14 109 * @return string[]|\Drupal\Component\Render\MarkupInterface[]
Chris@14 110 * The messages of given type.
Chris@14 111 */
Chris@14 112 public function messagesByType($type);
Chris@14 113
Chris@14 114 /**
Chris@14 115 * Deletes all messages.
Chris@14 116 *
Chris@14 117 * @return string[]|\Drupal\Component\Render\MarkupInterface[]
Chris@14 118 * The deleted messages.
Chris@14 119 */
Chris@14 120 public function deleteAll();
Chris@14 121
Chris@14 122 /**
Chris@14 123 * Deletes all messages of a certain type.
Chris@14 124 *
Chris@14 125 * @param string $type
Chris@14 126 * The messages' type. Either self::TYPE_STATUS, self::TYPE_WARNING, or
Chris@14 127 * self::TYPE_ERROR.
Chris@14 128 *
Chris@14 129 * @return string[]|\Drupal\Component\Render\MarkupInterface[]
Chris@14 130 * The deleted messages of given type.
Chris@14 131 */
Chris@14 132 public function deleteByType($type);
Chris@14 133
Chris@14 134 }