File indexing completed on 2025-01-26 05:30:06
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Wildfire 0017 * @subpackage Plugin 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 0024 /** 0025 * A message envelope that can be passed to Zend_Wildfire_Plugin_FirePhp to be 0026 * logged to Firebug instead of a variable. 0027 * 0028 * @category Zend 0029 * @package Zend_Wildfire 0030 * @subpackage Plugin 0031 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0032 * @license http://framework.zend.com/license/new-bsd New BSD License 0033 */ 0034 class Zend_Wildfire_Plugin_FirePhp_Message 0035 { 0036 /** 0037 * The style of the message 0038 * @var string 0039 */ 0040 protected $_style = null; 0041 0042 /** 0043 * The label of the message 0044 * @var string 0045 */ 0046 protected $_label = null; 0047 0048 /** 0049 * The message value 0050 * @var mixed 0051 */ 0052 protected $_message = null; 0053 0054 /** 0055 * Flag indicating if message buffering is enabled 0056 * @var boolean 0057 */ 0058 protected $_buffered = false; 0059 0060 /** 0061 * Flag indicating if message should be destroyed and not delivered 0062 * @var boolean 0063 */ 0064 protected $_destroy = false; 0065 0066 /** 0067 * Random unique ID used to identify message in comparison operations 0068 * @var string 0069 */ 0070 protected $_ruid = false; 0071 0072 /** 0073 * Options for the object 0074 * @var array 0075 */ 0076 protected $_options = array( 0077 'traceOffset' => null, /* The offset in the trace which identifies the source of the message */ 0078 'includeLineNumbers' => null /* Whether to include line and file info for this message */ 0079 ); 0080 0081 /** 0082 * Creates a new message with the given style and message 0083 * 0084 * @param string $style Style of the message. 0085 * @param mixed $message The message 0086 * @return void 0087 */ 0088 function __construct($style, $message) 0089 { 0090 $this->_style = $style; 0091 $this->_message = $message; 0092 $this->_ruid = md5(microtime().mt_rand()); 0093 } 0094 0095 /** 0096 * Set the label of the message 0097 * 0098 * @param string $label The label to be set 0099 * @return void 0100 */ 0101 public function setLabel($label) 0102 { 0103 $this->_label = $label; 0104 } 0105 0106 /** 0107 * Get the label of the message 0108 * 0109 * @return string The label of the message 0110 */ 0111 public function getLabel() 0112 { 0113 return $this->_label; 0114 } 0115 0116 /** 0117 * Enable or disable message buffering 0118 * 0119 * If a message is buffered it can be updated for the duration of the 0120 * request and is only flushed at the end of the request. 0121 * 0122 * @param boolean $buffered TRUE to enable buffering FALSE otherwise 0123 * @return boolean Returns previous buffering value 0124 */ 0125 public function setBuffered($buffered) 0126 { 0127 $previous = $this->_buffered; 0128 $this->_buffered = $buffered; 0129 return $previous; 0130 } 0131 0132 /** 0133 * Determine if buffering is enabled or disabled 0134 * 0135 * @return boolean Returns TRUE if buffering is enabled, FALSE otherwise. 0136 */ 0137 public function getBuffered() 0138 { 0139 return $this->_buffered; 0140 } 0141 0142 /** 0143 * Destroy the message to prevent delivery 0144 * 0145 * @param boolean $destroy TRUE to destroy FALSE otherwise 0146 * @return boolean Returns previous destroy value 0147 */ 0148 public function setDestroy($destroy) 0149 { 0150 $previous = $this->_destroy; 0151 $this->_destroy = $destroy; 0152 return $previous; 0153 } 0154 0155 /** 0156 * Determine if message should be destroyed 0157 * 0158 * @return boolean Returns TRUE if message should be destroyed, FALSE otherwise. 0159 */ 0160 public function getDestroy() 0161 { 0162 return $this->_destroy; 0163 } 0164 0165 /** 0166 * Set the style of the message 0167 * 0168 * @return void 0169 */ 0170 public function setStyle($style) 0171 { 0172 $this->_style = $style; 0173 } 0174 0175 /** 0176 * Get the style of the message 0177 * 0178 * @return string The style of the message 0179 */ 0180 public function getStyle() 0181 { 0182 return $this->_style; 0183 } 0184 0185 /** 0186 * Set the actual message to be sent in its final format. 0187 * 0188 * @return void 0189 */ 0190 public function setMessage($message) 0191 { 0192 $this->_message = $message; 0193 } 0194 0195 /** 0196 * Get the actual message to be sent in its final format. 0197 * 0198 * @return mixed Returns the message to be sent. 0199 */ 0200 public function getMessage() 0201 { 0202 return $this->_message; 0203 } 0204 0205 /** 0206 * Set a single option 0207 * 0208 * @param string $key The name of the option 0209 * @param mixed $value The value of the option 0210 * @return mixed The previous value of the option 0211 */ 0212 public function setOption($key, $value) 0213 { 0214 if(!array_key_exists($key,$this->_options)) { 0215 throw new Zend_Wildfire_Exception('Option with name "'.$key.'" does not exist!'); 0216 } 0217 $previous = $this->_options[$key]; 0218 $this->_options[$key] = $value; 0219 return $previous; 0220 } 0221 0222 /** 0223 * Retrieve a single option 0224 * 0225 * @param string $key The name of the option 0226 * @return mixed The value of the option 0227 */ 0228 public function getOption($key) 0229 { 0230 if(!array_key_exists($key,$this->_options)) { 0231 throw new Zend_Wildfire_Exception('Option with name "'.$key.'" does not exist!'); 0232 } 0233 return $this->_options[$key]; 0234 } 0235 0236 /** 0237 * Retrieve all options 0238 * 0239 * @return array All options 0240 */ 0241 public function getOptions() 0242 { 0243 return $this->_options; 0244 } 0245 } 0246