From: Richard Heyes Date: Sat, 6 Apr 2002 17:01:14 +0000 (+0000) Subject: * Added registerShutdownFunc() method X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~840 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3c0d670600550d4d67fc2988ded75caffe6db03;p=php * Added registerShutdownFunc() method --- diff --git a/pear/PEAR.php b/pear/PEAR.php index 98804a1704..2d4edd619c 100644 --- a/pear/PEAR.php +++ b/pear/PEAR.php @@ -40,6 +40,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; $GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; $GLOBALS['_PEAR_destructor_object_list'] = array(); +$GLOBALS['_PEAR_shutdown_funcs'] = array(); $GLOBALS['_PEAR_error_handler_stack'] = array(); /** @@ -172,6 +173,23 @@ class PEAR } } + // }}} + // {{{ registerShutdownFunc() + + /** + * Use this function to register a shutdown method for static + * classes. + * + * @access public + * @param mixed $func The function name (or array of class/method) to call + * @param mixed $args The arguments to pass to the function + * @return void + */ + function registerShutdownFunc($func, $args = array()) + { + $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); + } + // }}} // {{{ isError() @@ -486,6 +504,13 @@ function _PEAR_call_destructors() // not called more than once. $_PEAR_destructor_object_list = array(); } + + // Now call the shutdown functions + if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { + foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { + call_user_func_array($value[0], $value[1]); + } + } } // }}}