]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
Method redirectToConfiguredUrl() does now append the suffix '_url' to all config...
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
index d4eabd793f3564724250b78ec9e669c6f592b56e..d548e58433fc0a62a4a408b792aa234d3eb79a92 100644 (file)
@@ -53,6 +53,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $searchInstance = null;
 
+       /**
+        * Update criteria instance
+        */
+       private $updateInstance = null;
+
        /**
         * The file I/O instance for the template loader
         */
@@ -211,6 +216,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @todo        This is old code. Do we still need this old lost code?
         */
        public function __destruct() {
+               // Flush any updated entries to the database
+               $this->flushPendingUpdates();
+
                // Is this object already destroyed?
                if ($this->__toString() != 'DestructedObject') {
                        // Destroy all informations about this class but keep some text about it alive
@@ -360,6 +368,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $this->searchInstance;
        }
 
+       /**
+        * Setter for update instance
+        *
+        * @param       $updateInstance         Searchable criteria instance
+        * @return      void
+        */
+       public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) {
+               $this->updateInstance = $updateInstance;
+       }
+
+       /**
+        * Getter for update instance
+        *
+        * @return      $updateInstance         Updateable criteria instance
+        */
+       public final function getUpdateInstance () {
+               return $this->updateInstance;
+       }
+
        /**
         * Setter for resolver instance
         *
@@ -1071,6 +1098,28 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        public final function getControllerInstance () {
                return $this->controllerInstance;
        }
+
+       /**
+        * Flushs all pending updates to the database layer
+        *
+        * @return      void
+        */
+       public function flushPendingUpdates () {
+               // Get result instance
+               $resultInstance = $this->getResultInstance();
+
+               // Do we have data to update?
+               if ((is_object($resultInstance)) && ($resultInstance->ifDataNeedsFlush())) {
+                       // Get wrapper class name config entry
+                       $configEntry = $resultInstance->getUpdateInstance()->getWrapperConfigEntry();
+
+                       // Create object instance
+                       $wrapperInstance = ObjectFactory::createObjectByConfiguredName($configEntry);
+
+                       // Yes, then send the whole result to the database layer
+                       $wrapperInstance->doUpdateByResult($this->getResultInstance());
+               } // END - if
+       }
 }
 
 // [EOF]