diff options
author | xue <> | 2006-02-28 02:58:03 +0000 |
---|---|---|
committer | xue <> | 2006-02-28 02:58:03 +0000 |
commit | 5e4787d64cc4e70d115e5982f6d1b3bf6ffa5afe (patch) | |
tree | 84561ee24e7392ff2436b39d33fe1a3b390370de /framework | |
parent | 2617f1d34a9ec366fefea3db010748a2dcdb46a1 (diff) |
a little refactoring of autoload and error handler initialization.
Diffstat (limited to 'framework')
-rw-r--r-- | framework/core.php | 29 | ||||
-rw-r--r-- | framework/prado.php | 12 |
2 files changed, 32 insertions, 9 deletions
diff --git a/framework/core.php b/framework/core.php index c3ac048b..bac24ca2 100644 --- a/framework/core.php +++ b/framework/core.php @@ -402,6 +402,35 @@ class PradoBase }
/**
+ * Initializes error handlers.
+ * This method set error and exception handlers to be functions
+ * defined in this class.
+ */
+ public static function initErrorHandlers()
+ {
+ /**
+ * Sets error handler to be Prado::phpErrorHandler
+ */
+ set_error_handler(array('PradoBase','phpErrorHandler'),error_reporting());
+ /**
+ * Sets exception handler to be Prado::exceptionHandler
+ */
+ set_exception_handler(array('PradoBase','exceptionHandler'));
+ }
+
+ /**
+ * Class autoload loader.
+ * This method is provided to be invoked within an __auload() magic method.
+ * @param string class name
+ */
+ public static function autoload($className)
+ {
+ include_once($className.self::CLASS_FILE_EXT);
+ if(!class_exists($className,false) && !interface_exists($className,false))
+ self::fatalError("Class file for '$className' cannot be found.");
+ }
+
+ /**
* @return string a string that can be displayed on your Web page showing powered-by-PRADO information
*/
public static function poweredByPrado()
diff --git a/framework/prado.php b/framework/prado.php index eb38ae9d..59268105 100644 --- a/framework/prado.php +++ b/framework/prado.php @@ -38,20 +38,14 @@ if(!function_exists('__autoload')) {
function __autoload($className)
{
- include_once($className.Prado::CLASS_FILE_EXT);
- if(!class_exists($className,false) && !interface_exists($className,false))
- Prado::fatalError("Class file for '$className' cannot be found.");
+ Prado::autoload($className);
}
}
/**
- * Sets error handler to be Prado::phpErrorHandler
+ * Initializes error and exception handlers
*/
-set_error_handler(array('Prado','phpErrorHandler'),error_reporting());
-/**
- * Sets exception handler to be Prado::exceptionHandler
- */
-set_exception_handler(array('Prado','exceptionHandler'));
+Prado::initErrorHandlers();
/**
* Includes TApplication class file
|