00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Core_Model_Message
00035 {
00036 const ERROR = 'error';
00037 const WARNING = 'warning';
00038 const NOTICE = 'notice';
00039 const SUCCESS = 'success';
00040
00041 protected function _factory($code, $type, $class='', $method='')
00042 {
00043 switch (strtolower($type)) {
00044 case self::ERROR :
00045 $message = new Mage_Core_Model_Message_Error($code);
00046 break;
00047 case self::WARNING :
00048 $message = new Mage_Core_Model_Message_Warning($code);
00049 break;
00050 case self::SUCCESS :
00051 $message = new Mage_Core_Model_Message_Success($code);
00052 break;
00053 default:
00054 $message = new Mage_Core_Model_Message_Notice($code);
00055 break;
00056 }
00057 $message->setClass($class);
00058 $message->setMethod($method);
00059
00060 return $message;
00061 }
00062
00063 public function error($code, $class='', $method='')
00064 {
00065 return $this->_factory($code, self::ERROR, $class, $method);
00066 }
00067
00068 public function warning($code, $class='', $method='')
00069 {
00070 return $this->_factory($code, self::WARNING, $class, $method);
00071 }
00072
00073 public function notice($code, $class='', $method='')
00074 {
00075 return $this->_factory($code, self::NOTICE, $class, $method);
00076 }
00077
00078 public function success($code, $class='', $method='')
00079 {
00080 return $this->_factory($code, self::SUCCESS, $class, $method);
00081 }
00082 }