Move storing the task as well as registering the shutdown into the backend.
authorGunnar Wrobel <p@rdus.de>
Wed, 3 Mar 2010 10:45:31 +0000 (11:45 +0100)
committerGunnar Wrobel <p@rdus.de>
Wed, 3 Mar 2010 10:45:31 +0000 (11:45 +0100)
framework/LoginTasks/lib/Horde/LoginTasks.php
framework/LoginTasks/lib/Horde/LoginTasks/Backend.php
framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php

index 35fbfe9..3dacf2f 100644 (file)
@@ -103,13 +103,13 @@ class Horde_LoginTasks
         }
 
         /* Retrieves a cached tasklist or make sure one is created. */
-        $this->_tasklist = $this->_backend->getTaskListFromCache();
+        $this->_tasklist = $this->_backend->getTasklistFromCache();
 
         if (empty($this->_tasklist)) {
             $this->_createTaskList();
         }
 
-        register_shutdown_function(array($this, 'shutdown'));
+        $this->_backend->registerShutdown(array($this, 'shutdown'));
     }
 
     /**
@@ -118,7 +118,7 @@ class Horde_LoginTasks
     public function shutdown()
     {
         if (isset($this->_tasklist)) {
-            $_SESSION['horde_logintasks'][$this->_app] = serialize($this->_tasklist);
+            $this->_tasklist = $this->_backend->storeTasklistInCache($this->_tasklist);
         }
     }
 
index 150260a..44a9395 100644 (file)
@@ -29,4 +29,22 @@ abstract class Horde_LoginTasks_Backend
      * if no task list was cached.
      */
     abstract public function getTasklistFromCache();
+
+    /**
+     * Store a login tasklist in the cache.
+     *
+     * @param Horde_LoginTasks_Tasklist|boolean The tasklist to be stored.
+     *
+     * @return NULL
+     */
+    abstract public function storeTasklistInCache($tasklist);
+
+    /**
+     * Register the shutdown handler.
+     *
+     * @param array The shutdown function
+     *
+     * @return NULL
+     */
+    abstract public function registerShutdown($shutdown);
 }
\ No newline at end of file
index 544b070..2ae4660 100644 (file)
@@ -55,4 +55,28 @@ extends Horde_LoginTasks_Backend
         }
         return false;
     }
+
+    /**
+     * Store a login tasklist in the cache.
+     *
+     * @param Horde_LoginTasks_Tasklist|boolean The tasklist to be stored.
+     *
+     * @return NULL
+     */
+    public function storeTasklistInCache($tasklist)
+    {
+        $_SESSION['horde_logintasks'][$this->_app] = serialize($tasklist);
+    }
+
+    /**
+     * Register the shutdown handler.
+     *
+     * @param array The shutdown function
+     *
+     * @return NULL
+     */
+    public function registerShutdown($shutdown)
+    {
+        register_shutdown_function($shutdown);
+    }
 }
\ No newline at end of file