oxexceptiontodisplay.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxExceptionToDisplay implements oxIDisplayError
00008 {
00014     private $_sMessage;
00015 
00021     protected $_blDebug = false;
00022 
00028     private $_sStackTrace;
00029 
00035     private $_aValues;
00036 
00042     private $_sType;
00043 
00051     public function setStackTrace($sStackTrace)
00052     {
00053         $this->_sStackTrace = $sStackTrace;
00054     }
00055 
00061     public function getStackTrace()
00062     {
00063         return $this->_sStackTrace;
00064     }
00065 
00073     public function setValues( $aValues )
00074     {
00075         $this->_aValues = $aValues;
00076     }
00077 
00086     public function addValue( $sName, $sValue )
00087     {
00088         $this->_aValues[$sName] = $sValue;
00089     }
00090 
00098     public function setExceptionType( $sType )
00099     {
00100         $this->_sType = $sType;
00101     }
00102 
00108     public function getErrorClassType()
00109     {
00110         return $this->_sType;
00111     }
00112 
00120     public function getValue( $sName )
00121     {
00122         return $this->_aValues[$sName];
00123     }
00124 
00132     public function setDebug( $bl )
00133     {
00134         $this->_blDebug = $bl;
00135     }
00136 
00144     public function setMessage($sMessage)
00145     {
00146         $this->_sMessage = $sMessage;
00147     }
00148 
00155     public function setMessageArgs()
00156     {
00157         $this->_aMessageArgs = func_get_args();
00158     }
00159 
00165     public function getOxMessage()
00166     {
00167         if ( $this->_blDebug ) {
00168             return $this;
00169         } else {
00170              $sString = oxLang::getInstance()->translateString($this->_sMessage);
00171 
00172              if ( !empty( $this->_aMessageArgs ) ) {
00173                  $sString = vsprintf( $sString, $this->_aMessageArgs );
00174              }
00175 
00176              return $sString;
00177         }
00178     }
00179 
00185     public function __toString()
00186     {
00187         $sRes = $this->getErrorClassType() . " (time: " . date('Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime()) . "): " . $this->getOxMessage() . " \n Stack Trace: " . $this->getStackTrace() . "\n";
00188         foreach ( $this->_aValues as $key => $value ) {
00189             $sRes .= $key. " => ". $value . "\n";
00190         }
00191         return $sRes;
00192     }
00193 }