[FEATURE] t3lib_FlashMessage: separate message-classes from rendering
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 10 Jun 2011 21:31:22 +0000 (23:31 +0200)
committerAndreas Wolf <andreas.wolf@ikt-werk.de>
Sun, 12 Jun 2011 16:19:44 +0000 (18:19 +0200)
Separate class-fetching from HTML-rendering.

Change-Id: Ic8994aebaf4c1c22919054b7a6720b51bdcbc4c5
Resolves: #27367
Reviewed-on: http://review.typo3.org/2646
Reviewed-by: Markus Klein
Reviewed-by: Kay Strobach
Tested-by: Kay Strobach
Reviewed-by: Andreas Wolf
Tested-by: Andreas Wolf
t3lib/class.t3lib_flashmessage.php

index 13d6f71..5459af2 100644 (file)
@@ -43,6 +43,17 @@ class t3lib_FlashMessage extends t3lib_message_AbstractMessage {
        protected $storeInSession = FALSE;
 
        /**
+        * @var string The message severity class names
+        */
+       protected $classes = array(
+               self::NOTICE  => 'notice',
+               self::INFO    => 'information',
+               self::OK      => 'ok',
+               self::WARNING => 'warning',
+               self::ERROR   => 'error',
+       );
+
+       /**
         * Constructor for a flash message
         *
         * @param       string  The message.
@@ -80,25 +91,26 @@ class t3lib_FlashMessage extends t3lib_message_AbstractMessage {
        }
 
        /**
+        * Gets the message severity class name
+        *
+        * @return      string  The message severity class name
+        */
+       public function getClass() {
+               return 'message-' . $this->classes[$this->severity];
+       }
+
+       /**
         * Renders the flash message.
         *
         * @return      string  The flash message as HTML.
         */
        public function render() {
-               $classes = array(
-                       self::NOTICE =>  'notice',
-                       self::INFO =>    'information',
-                       self::OK =>      'ok',
-                       self::WARNING => 'warning',
-                       self::ERROR =>   'error',
-               );
-
                $title = '';
                if (!empty($this->title)) {
                        $title = '<div class="message-header">' . $this->title . '</div>';
                }
 
-               $message = '<div class="typo3-message message-' . $classes[$this->severity] . '">'
+               $message = '<div class="typo3-message ' . $this->getClass() . '">'
                                . $title
                                . '<div class="message-body">' . $this->message . '</div>'
                                . '</div>';