[BUGFIX] Rename File after renaming class
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Mvc / Controller / FlashMessageContainer.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Mvc\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2009 Sebastian Kurf├╝rst <sebastian@typo3.org>
8 * All rights reserved
9 *
10 * This class is a backport of the corresponding class of FLOW3.
11 * All credits go to the v5 team.
12 *
13 * This script is part of the TYPO3 project. The TYPO3 project is
14 * free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * The GNU General Public License can be found at
20 * http://www.gnu.org/copyleft/gpl.html.
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * This is a container for all Flash Messages. It is of scope session, but as Extbase
31 * has no session scope, we need to save it manually.
32 *
33 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
34 * @scope session
35 * @api
36 */
37 class FlashMessageContainer implements \TYPO3\CMS\Core\SingletonInterface {
38
39 /**
40 * Add another flash message.
41 * Severity can be specified and must be one of
42 * t3lib_FlashMessage::NOTICE,
43 * t3lib_FlashMessage::INFO,
44 * t3lib_FlashMessage::OK,
45 * t3lib_FlashMessage::WARNING,
46 * t3lib_FlashMessage::ERROR
47 *
48 * @param string $message
49 * @param string $title optional message title
50 * @param integer $severity optional severity code. One of the t3lib_FlashMessage constants
51 * @throws \InvalidArgumentException
52 * @return void
53 * @api
54 */
55 public function add($message, $title = '', $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK) {
56 if (!is_string($message)) {
57 throw new \InvalidArgumentException('The flash message must be string, ' . gettype($message) . ' given.', 1243258395);
58 }
59 /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
60 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $message, $title, $severity, TRUE);
61 \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($flashMessage);
62 }
63
64 /**
65 * Get all flash messages currently available.
66 *
67 * @return array<t3lib_FlashMessage> An array of flash messages
68 * @api
69 * @see t3lib_FlashMessage
70 */
71 public function getAllMessages() {
72 return \TYPO3\CMS\Core\Messaging\FlashMessageQueue::getAllMessages();
73 }
74
75 /**
76 * Reset all flash messages.
77 *
78 * @return void
79 * @api
80 */
81 public function flush() {
82 \TYPO3\CMS\Core\Messaging\FlashMessageQueue::getAllMessagesAndFlush();
83 }
84
85 /**
86 * Get all flash messages currently available. And removes them from the session.
87 *
88 * @return array<t3lib_FlashMessage> An array of flash messages
89 * @see t3lib_FlashMessage
90 * @api
91 */
92 public function getAllMessagesAndFlush() {
93 return \TYPO3\CMS\Core\Messaging\FlashMessageQueue::getAllMessagesAndFlush();
94 }
95
96 }
97
98
99 ?>