add SMARTY_EXCEPTION_HANDLER constant to determine if internal exception handling is enabled

This commit is contained in:
monte.ohrt
2009-07-03 14:48:38 +00:00
parent b288d014f4
commit 3463a3a090

View File

@@ -54,6 +54,14 @@ define('SMARTY_CACHING_OFF', 0);
define('SMARTY_CACHING_LIFETIME_CURRENT', 1);
define('SMARTY_CACHING_LIVETIME_SAVED', 2);
/**
* define exception handling
*/
if (!defined('SMARTY_EXCEPTION_HANDLER')) {
define('SMARTY_EXCEPTION_HANDLER', 1);
}
/**
* load required base class for creation of the smarty object
*/
@@ -142,7 +150,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
public $default_config_type = 'file';
// class used for cacher
public $cacher_class = 'Smarty_Internal_Cacher_InlineCode';
// exception handler: set null to disable
// exception handler: define SMARTY_EXCEPTION_HANDLER to 0 to disable
public $exception_handler = array('SmartyException', 'getStaticException');
// cached template objects
public $template_objects = null;
@@ -193,7 +201,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
}
$this->start_time = $this->_get_time();
// set exception handler
if (!empty($this->exception_handler))
if (SMARTY_EXCEPTION_HANDLER && !empty($this->exception_handler))
set_exception_handler($this->exception_handler);
// set default dirs
$this->template_dir = array('.' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR);
@@ -244,7 +252,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
public function __destruct()
{
// restore to previous exception handler, if any
if (!empty($this->exception_handler))
if (SMARTY_EXCEPTION_HANDLER && !empty($this->exception_handler))
restore_exception_handler();
}