*/
private $searchInstance = null;
+ /**
+ * Update criteria instance
+ */
+ private $updateInstance = null;
+
/**
* The file I/O instance for the template loader
*/
* @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
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
*
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]