1 | <?php |
||
25 | class Messenger |
||
26 | { |
||
27 | /** |
||
28 | * instance of the registry class |
||
29 | * |
||
30 | * @var Registry |
||
31 | */ |
||
32 | |||
33 | protected $_registry; |
||
34 | |||
35 | /** |
||
36 | * array of the action |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | |||
41 | protected $_actionArray = |
||
42 | [ |
||
43 | 'text' => null, |
||
44 | 'route' => null, |
||
45 | 'url' => null |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * options of the messenger |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | |||
54 | protected $_optionArray = |
||
55 | [ |
||
56 | 'className' => |
||
57 | [ |
||
58 | 'box' => ' rs-box-note', |
||
59 | 'title' => 'rs-title-note', |
||
60 | 'list' => 'rs-list-note', |
||
61 | 'link' => 'rs-button-note', |
||
62 | 'redirect' => 'rs-meta-redirect', |
||
63 | 'note' => |
||
64 | [ |
||
65 | 'success' => 'rs-is-success', |
||
66 | 'warning' => 'rs-is-warning', |
||
67 | 'error' => 'rs-is-error', |
||
68 | 'info' => 'rs-is-info' |
||
69 | ] |
||
70 | ] |
||
71 | ]; |
||
72 | |||
73 | /** |
||
74 | * constructor of the class |
||
75 | * |
||
76 | * @since 2.4.0 |
||
77 | * |
||
78 | * @param Registry $registry instance of the registry class |
||
79 | */ |
||
80 | |||
81 | public function __construct(Registry $registry) |
||
85 | |||
86 | /** |
||
87 | * init the class |
||
88 | * |
||
89 | * @since 3.0.0 |
||
90 | * |
||
91 | * @param array $optionArray options of the messenger |
||
92 | * |
||
93 | * @return self |
||
94 | */ |
||
95 | |||
96 | public function init(array $optionArray = []) : self |
||
101 | |||
102 | /** |
||
103 | * set the absolute redirect url |
||
104 | * |
||
105 | * @since 3.0.0 |
||
106 | * |
||
107 | * @param string $text text of the action |
||
108 | * @param string $url absolute url of the action |
||
109 | * |
||
110 | * @return self |
||
111 | */ |
||
112 | |||
113 | public function setUrl(string $text = null, string $url = null) : self |
||
123 | |||
124 | /** |
||
125 | * set the relative redirect url |
||
126 | * |
||
127 | * @since 3.0.0 |
||
128 | * |
||
129 | * @param string $text text of the action |
||
130 | * @param string $route relative route of the action |
||
131 | * |
||
132 | * @return self |
||
133 | */ |
||
134 | |||
135 | public function setRoute(string $text = null, string $route = null) : self |
||
145 | |||
146 | /** |
||
147 | * do the redirect |
||
148 | * |
||
149 | * @since 3.0.0 |
||
150 | * |
||
151 | * @param int $timeout timeout of the redirect |
||
152 | * |
||
153 | * @return self |
||
154 | */ |
||
155 | |||
156 | public function doRedirect(int $timeout = 2) : self |
||
161 | |||
162 | /** |
||
163 | * success message |
||
164 | * |
||
165 | * @since 3.0.0 |
||
166 | * |
||
167 | * @param string|array $message message of the success |
||
168 | * @param string $title title of the success |
||
169 | * |
||
170 | * @return string |
||
171 | */ |
||
172 | |||
173 | public function success($message = null, string $title = null) : string |
||
177 | |||
178 | /** |
||
179 | * info message |
||
180 | * |
||
181 | * @since 3.0.0 |
||
182 | * |
||
183 | * @param string|array $message message of the info |
||
184 | * @param string $title title of the info |
||
185 | * |
||
186 | * @return string |
||
187 | */ |
||
188 | |||
189 | public function info($message = null, string $title = null) : string |
||
193 | |||
194 | /** |
||
195 | * warning message |
||
196 | * |
||
197 | * @since 3.0.0 |
||
198 | * |
||
199 | * @param string|array $message message of the warning |
||
200 | * @param string $title message title of the warning |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | |||
205 | public function warning($message = null, string $title = null) : string |
||
209 | |||
210 | /** |
||
211 | * error message |
||
212 | * |
||
213 | * @since 3.0.0 |
||
214 | * |
||
215 | * @param string|array $message message of the error |
||
216 | * @param string $title title of the error |
||
217 | * |
||
218 | * @return string |
||
219 | */ |
||
220 | |||
221 | public function error($message = null, string $title = null) : string |
||
225 | |||
226 | /** |
||
227 | * render |
||
228 | * |
||
229 | * @since 3.0.0 |
||
230 | * |
||
231 | * @param string $type type of the flash |
||
232 | * @param string|array $message message of the flash |
||
233 | * @param string $title title of the flash |
||
234 | * |
||
235 | * @return string |
||
236 | */ |
||
237 | |||
238 | public function render(string $type = null, $message = null, string $title = null) : string |
||
296 | |||
297 | /** |
||
298 | * render action |
||
299 | * |
||
300 | * @since 3.0.0 |
||
301 | * |
||
302 | * @param string $type type of the flash |
||
303 | * |
||
304 | * @return string|null |
||
305 | */ |
||
306 | |||
307 | protected function _renderAction(string $type = null) : ?string |
||
340 | } |