]> granicus.if.org Git - php/commitdiff
* Added registerShutdownFunc() method
authorRichard Heyes <richard@php.net>
Sat, 6 Apr 2002 17:01:14 +0000 (17:01 +0000)
committerRichard Heyes <richard@php.net>
Sat, 6 Apr 2002 17:01:14 +0000 (17:01 +0000)
pear/PEAR.php

index 98804a17041eca5f199b5f9b7cf41cc518b924e3..2d4edd619cb6819682b28105ec02fd21d8121c66 100644 (file)
@@ -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]);
+        }
+    }
 }
 
 // }}}