|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /*************************************************************** 00004 * Copyright notice 00005 * 00006 * (c) 2009 Sebastian Kurfürst <sebastian@typo3.org> 00007 * All rights reserved 00008 * 00009 * This class is a backport of the corresponding class of FLOW3. 00010 * All credits go to the v5 team. 00011 * 00012 * This script is part of the TYPO3 project. The TYPO3 project is 00013 * free software; you can redistribute it and/or modify 00014 * it under the terms of the GNU General Public License as published by 00015 * the Free Software Foundation; either version 2 of the License, or 00016 * (at your option) any later version. 00017 * 00018 * The GNU General Public License can be found at 00019 * http://www.gnu.org/copyleft/gpl.html. 00020 * 00021 * This script is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * This copyright notice MUST APPEAR in all copies of the script! 00027 ***************************************************************/ 00028 00029 /** 00030 * This is a container for all Flash Messages. It is of scope session, but as Extbase 00031 * has no session scope, we need to save it manually. 00032 * 00033 * @version $Id: FlashMessages.php 1729 2009-11-25 21:37:20Z stucki $ 00034 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later 00035 * @scope session 00036 * @api 00037 */ 00038 class Tx_Extbase_MVC_Controller_FlashMessages implements t3lib_Singleton { 00039 00040 /** 00041 * Add another flash message. 00042 * Severity can be specified and must be one of 00043 * t3lib_FlashMessage::NOTICE, 00044 * t3lib_FlashMessage::INFO, 00045 * t3lib_FlashMessage::OK, 00046 * t3lib_FlashMessage::WARNING, 00047 * t3lib_FlashMessage::ERROR 00048 * 00049 * @param string $message 00050 * @param string $title optional message title 00051 * @param integer $severity optional severity code. One of the t3lib_FlashMessage constants 00052 * @return void 00053 * @api 00054 */ 00055 public function add($message, $title = '', $severity = t3lib_FlashMessage::OK) { 00056 if (!is_string($message)) { 00057 throw new InvalidArgumentException('The flash message must be string, ' . gettype($message) . ' given.', 1243258395); 00058 } 00059 $flashMessage = t3lib_div::makeInstance( 00060 't3lib_FlashMessage', 00061 $message, 00062 $title, 00063 $severity, 00064 TRUE 00065 ); 00066 t3lib_FlashMessageQueue::addMessage($flashMessage); 00067 } 00068 00069 /** 00070 * Get all flash messages currently available. 00071 * 00072 * @return array<string> An array of flash messages 00073 * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0. Use Use getAllMessages() instead 00074 */ 00075 public function getAll() { 00076 t3lib_div::logDeprecatedFunction(); 00077 $flashMessages = t3lib_FlashMessageQueue::getAllMessages(); 00078 $messages = array(); 00079 foreach ($flashMessages as $flashMessage) { 00080 $messages[] = $flashMessage->getMessage(); 00081 } 00082 return $messages; 00083 } 00084 00085 /** 00086 * Get all flash messages currently available. 00087 * 00088 * @return array<t3lib_FlashMessage> An array of flash messages 00089 * @api 00090 * @see t3lib_FlashMessage 00091 */ 00092 public function getAllMessages() { 00093 return t3lib_FlashMessageQueue::getAllMessages(); 00094 } 00095 00096 /** 00097 * Reset all flash messages. 00098 * 00099 * @return void 00100 * @api 00101 */ 00102 public function flush() { 00103 t3lib_FlashMessageQueue::getAllMessagesAndFlush(); 00104 } 00105 00106 /** 00107 * Get all flash messages currently available and delete them afterwards. 00108 * 00109 * @return array<string> 00110 * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0. Use getAllMessagesAndFlush() instead 00111 */ 00112 public function getAllAndFlush() { 00113 t3lib_div::logDeprecatedFunction(); 00114 $flashMessages = t3lib_FlashMessageQueue::getAllMessagesAndFlush(); 00115 $messages = array(); 00116 foreach ($flashMessages as $flashMessage) { 00117 $messages[] = $flashMessage->getMessage(); 00118 } 00119 return $messages; 00120 } 00121 00122 /** 00123 * Get all flash messages currently available. And removes them from the session. 00124 * 00125 * @return array<t3lib_FlashMessage> An array of flash messages 00126 * @see t3lib_FlashMessage 00127 * @api 00128 */ 00129 public function getAllMessagesAndFlush() { 00130 return t3lib_FlashMessageQueue::getAllMessagesAndFlush(); 00131 } 00132 00133 } 00134 00135 ?>
1.8.0