summaryrefslogtreecommitdiff
path: root/framework/Exceptions/TException.php
diff options
context:
space:
mode:
authorhaertl.mike <>2009-02-11 15:24:27 +0000
committerhaertl.mike <>2009-02-11 15:24:27 +0000
commitf6a77cd876890c71285574480d61f836bf204421 (patch)
tree45650975490ff77888a3cbf6be5ac5173ba8ea4c /framework/Exceptions/TException.php
parentc8861d5cfc5779d2c7edd450a66d60b590364fc5 (diff)
Added caching of message files to TException
Diffstat (limited to 'framework/Exceptions/TException.php')
-rw-r--r--framework/Exceptions/TException.php21
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;
}
/**