From 580adc82636e33314103d279f1bcd94a05dfbb7f Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sun, 10 Jul 2011 04:26:41 -0400
Subject: [PATCH] - Add add_shutdown_function() method. Make possible to call user function before destoying all objects (e.g. session)
---
program/include/rcmail.php | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index fe2d994..dba846d 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -124,6 +124,7 @@
private $address_books = array();
private $caches = array();
private $action_map = array();
+ private $shutdown_functions = array();
/**
@@ -1142,6 +1143,9 @@
*/
public function shutdown()
{
+ foreach ($this->shutdown_functions as $function)
+ call_user_func($function);
+
if (is_object($this->smtp))
$this->smtp->disconnect();
@@ -1183,6 +1187,19 @@
/**
+ * Registers shutdown function to be executed on shutdown.
+ * The functions will be executed before destroying any
+ * objects like smtp, imap, session, etc.
+ *
+ * @param callback Function callback
+ */
+ public function add_shutdown_function($function)
+ {
+ $this->shutdown_functions[] = $function;
+ }
+
+
+ /**
* Generate a unique token to be used in a form request
*
* @return string The request token
--
Gitblit v1.9.1