comparison core/lib/Drupal/Core/Messenger/MessengerInterface.php @ 14:1fec387a4317

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