Alexander Nicolaysen Sørnes : objectManager: Add object caching support

Chris Morgan cmorgan at winehq.org
Mon Oct 8 14:45:34 CDT 2007


Module: appdb
Branch: master
Commit: c95da59dd1823947a1e0a18e74cef0ec36d6d1d4
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=c95da59dd1823947a1e0a18e74cef0ec36d6d1d4

Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date:   Mon Oct  8 11:43:24 2007 +0200

objectManager: Add object caching support

---

 include/objectManager.php |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/include/objectManager.php b/include/objectManager.php
index 807824b..48366e5 100644
--- a/include/objectManager.php
+++ b/include/objectManager.php
@@ -15,11 +15,36 @@ class ObjectManager
     private $sReturnTo;
     private $oMultiPage;
     private $oTableRow;
+    private $oObject; /* Store an instance of the object of the class
+                         we are working with.  This is useful if
+                         we are calling object functions which modify
+                         the object without storing it in the database,
+                         and then call objectManager functions which
+                         operate on the object, such as in processForm
+                         where we first run the object's getOutputEditorValues()
+                         and then objectManager's delete_entry(). */
 
     // an array of common responses used when replying to
     // queued entries
     private $aCommonResponses;
 
+    /* Get an instance of the object of the class we are working with */
+    private function getObject()
+    {
+        if(!$this->oObject)
+            $this->oObject = new $this->sClass($this->iId);
+
+        return $this->oObject;
+    }
+
+    private function setId($iId)
+    {
+        $this->iId = $iId;
+
+        if($this->oObject)
+            $this->oObject = new $this->sClass($this->iId);
+    }
+
     public function getClass()
     {
       return $this->sClass;
@@ -466,7 +491,7 @@ class ObjectManager
     {
         $this->checkMethods(array("delete", "canEdit"));
 
-        $oObject = new $this->sClass($this->iId);
+        $oObject = $this->getObject();
 
         if(!$oObject->objectGetId())
             return FALSE;
@@ -933,6 +958,11 @@ class ObjectManager
                 break;
 
             case "Delete":
+                /* Heere we call an objectManager function instead
+                   of a function of the object's class.  Thus we
+                   need to store the object so changes in
+                   getOutputEditorValues() are caught. */
+                $this->oObject = $oObject;
                 $this->delete_entry($aClean['sReplyText']);
                 break;
 




More information about the wine-cvs mailing list