diff options
author | haertl.mike <> | 2009-02-11 15:24:27 +0000 |
---|---|---|
committer | haertl.mike <> | 2009-02-11 15:24:27 +0000 |
commit | f6a77cd876890c71285574480d61f836bf204421 (patch) | |
tree | 45650975490ff77888a3cbf6be5ac5173ba8ea4c /framework | |
parent | c8861d5cfc5779d2c7edd450a66d60b590364fc5 (diff) |
Added caching of message files to TException
Diffstat (limited to 'framework')
-rw-r--r-- | framework/Exceptions/TException.php | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/framework/Exceptions/TException.php b/framework/Exceptions/TException.php index c6a87b4d..073b587d 100644 --- a/framework/Exceptions/TException.php +++ b/framework/Exceptions/TException.php @@ -35,6 +35,7 @@ class TException extends Exception
{
private $_errorCode='';
+ static $_messageCache=array(); /**
* Constructor.
@@ -64,16 +65,20 @@ class TException extends Exception protected function translateErrorMessage($key)
{
$msgFile=$this->getErrorMessageFile();
- if(($entries=@file($msgFile))!==false)
- {
- foreach($entries as $entry)
+ + // Cache messages + if (!isset(self::$_messageCache[$msgFile])) + { + if(($entries=@file($msgFile))!==false)
{
- @list($code,$message)=explode('=',$entry,2);
- if(trim($code)===$key)
- return trim($message);
+ foreach($entries as $entry)
+ {
+ @list($code,$message)=explode('=',$entry,2);
+ self::$_messageCache[$msgFile][trim($code)]=trim($message); + }
}
- }
- return $key;
+ } + return isset(self::$_messageCache[$msgFile][$key]) ? self::$_messageCache[$msgFile][$key] : $key;
}
/**
|