From 5e4787d64cc4e70d115e5982f6d1b3bf6ffa5afe Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 28 Feb 2006 02:58:03 +0000 Subject: a little refactoring of autoload and error handler initialization. --- framework/core.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'framework/core.php') diff --git a/framework/core.php b/framework/core.php index c3ac048b..bac24ca2 100644 --- a/framework/core.php +++ b/framework/core.php @@ -401,6 +401,35 @@ class PradoBase return '3.0b'; } + /** + * 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 */ -- cgit v1.2.3