All filters rewritten to throw FilterChainException
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
index d4eabd793f3564724250b78ec9e669c6f592b56e..acea78ded4ebb8c49137d5e5648f86ea11c55906 100644 (file)
@@ -5,7 +5,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007 - 2009 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
-       /**
-        * Instance to an application helper class
-        */
-       private static $applicationInstance = null;
-
-       /**
-        * The language instance for the template loader
-        */
-       private static $langInstance = null;
-
-       /**
-        * Debug instance
-        */
-       private static $debugInstance = null;
-
        /**
         * Instance of a request class
         */
        /**
         * Instance of a request class
         */
@@ -53,6 +38,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $searchInstance = null;
 
         */
        private $searchInstance = null;
 
+       /**
+        * Update criteria instance
+        */
+       private $updateInstance = null;
+
        /**
         * The file I/O instance for the template loader
         */
        /**
         * The file I/O instance for the template loader
         */
@@ -159,6 +149,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const EXCEPTION_ASSERTION_FAILED             = 0x037;
        const EXCEPTION_FILE_CANNOT_BE_READ          = 0x038;
        const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
        const EXCEPTION_ASSERTION_FAILED             = 0x037;
        const EXCEPTION_FILE_CANNOT_BE_READ          = 0x038;
        const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
+       const EXCEPTION_FILTER_CHAIN_INTERCEPTED     = 0x040;
 
        /**
         * In the super constructor these system classes shall be ignored or else
 
        /**
         * In the super constructor these system classes shall be ignored or else
@@ -184,11 +175,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                "GzipCompressor",                               // GZIP compressor
        );
 
                "GzipCompressor",                               // GZIP compressor
        );
 
-       /* No longer used:
-       */
-
        /**
        /**
-        * Private super constructor
+        * Protected super constructor
         *
         * @param       $className      Name of the class
         * @return      void
         *
         * @param       $className      Name of the class
         * @return      void
@@ -211,6 +199,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @todo        This is old code. Do we still need this old lost code?
         */
        public function __destruct() {
         * @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
                // Is this object already destroyed?
                if ($this->__toString() != 'DestructedObject') {
                        // Destroy all informations about this class but keep some text about it alive
@@ -360,6 +351,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $this->searchInstance;
        }
 
                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
         *
        /**
         * Setter for resolver instance
         *
@@ -407,7 +417,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      void
         */
        public final function setDebugInstance (DebugMiddleware $debugInstance) {
         * @return      void
         */
        public final function setDebugInstance (DebugMiddleware $debugInstance) {
-               self::$debugInstance = $debugInstance;
+               Registry::getRegistry()->addInstance('debug', $debugInstance);
        }
 
        /**
        }
 
        /**
@@ -416,7 +426,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $debugInstance  Instance to class DebugConsoleOutput or DebugWebOutput
         */
        public final function getDebugInstance () {
         * @return      $debugInstance  Instance to class DebugConsoleOutput or DebugWebOutput
         */
        public final function getDebugInstance () {
-               return self::$debugInstance;
+               $debugInstance = Registry::getRegistry()->getInstance('debug');
+               return $debugInstance;
        }
 
        /**
        }
 
        /**
@@ -432,10 +443,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        /**
         * Getter for web output instance
         *
        /**
         * Getter for web output instance
         *
-        * @return      $webOutput - Instance to class WebOutput
+        * @return      $webOutputInstance - Instance to class WebOutput
         */
        public final function getWebOutputInstance () {
         */
        public final function getWebOutputInstance () {
-               return Registry::getRegistry()->getInstance('web_output');
+               $webOutputInstance = Registry::getRegistry()->getInstance('web_output');
+               return $webOutputInstance;
        }
 
        /**
        }
 
        /**
@@ -446,7 +458,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      void
         */
        public final function setDatabaseInstance (DatabaseConnection $dbInstance) {
         * @return      void
         */
        public final function setDatabaseInstance (DatabaseConnection $dbInstance) {
-               Registry::getRegistry()->addInstance('dbInstance', $dbInstance);
+               Registry::getRegistry()->addInstance('db_instance', $dbInstance);
        }
 
        /**
        }
 
        /**
@@ -460,7 +472,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 
                // Is the registry there and initialized?
                if ((class_exists('Registry')) && (Registry::isInitialized() === true)) {
 
                // Is the registry there and initialized?
                if ((class_exists('Registry')) && (Registry::isInitialized() === true)) {
-                       $dbInstance = Registry::getRegistry()->getInstance('dbInstance');
+                       $dbInstance = Registry::getRegistry()->getInstance('db_instance');
                } // END - if
 
                // Return instance
                } // END - if
 
                // Return instance
@@ -470,20 +482,21 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        /**
         * Setter for compressor channel
         *
        /**
         * Setter for compressor channel
         *
-        * @param               $compressorChannel      An instance of CompressorChannel
+        * @param               $compressorInstance             An instance of CompressorChannel
         * @return      void
         */
         * @return      void
         */
-       public final function setCompressorChannel (CompressorChannel $compressorChannel) {
-               Registry::getRegistry()->addInstance('compressor', $compressorChannel);
+       public final function setCompressorChannel (CompressorChannel $compressorInstance) {
+               Registry::getRegistry()->addInstance('compressor', $compressorInstance);
        }
 
        /**
         * Getter for compressor channel
         *
        }
 
        /**
         * Getter for compressor channel
         *
-        * @return      $compressor     The compressor channel
+        * @return      $compressorInstance             The compressor channel
         */
        public final function getCompressorChannel () {
         */
        public final function getCompressorChannel () {
-               return Registry::getRegistry()->getInstance('compressor');
+               $compressorInstance = Registry::getRegistry()->getInstance('compressor');
+               return $compressorInstance;
        }
 
        /**
        }
 
        /**
@@ -492,7 +505,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $applicationInstance    An instance of a manageable application helper class
         */
        protected final function getApplicationInstance () {
         * @return      $applicationInstance    An instance of a manageable application helper class
         */
        protected final function getApplicationInstance () {
-               return self::$applicationInstance;
+               $applicationInstance = Registry::getRegistry()->getInstance('application');
+               return $applicationInstance;
        }
 
        /**
        }
 
        /**
@@ -502,7 +516,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      void
         */
        public final function setApplicationInstance (ManageableApplication $applicationInstance) {
         * @return      void
         */
        public final function setApplicationInstance (ManageableApplication $applicationInstance) {
-               self::$applicationInstance = $applicationInstance;
+               Registry::getRegistry()->addInstance('application', $applicationInstance);
        }
 
        /**
        }
 
        /**
@@ -645,7 +659,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $langInstance   An instance to the language sub-system
         */
        protected final function getLanguageInstance () {
         * @return      $langInstance   An instance to the language sub-system
         */
        protected final function getLanguageInstance () {
-               return self::$langInstance;
+               $langInstance = Registry::getRegistry()->getInstance('language');
+               return $langInstance;
        }
 
        /**
        }
 
        /**
@@ -656,7 +671,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @see         LanguageSystem
         */
        public final function setLanguageInstance (ManageableLanguage $langInstance) {
         * @see         LanguageSystem
         */
        public final function setLanguageInstance (ManageableLanguage $langInstance) {
-               self::$langInstance = $langInstance;
+               Registry::getRegistry()->addInstance('language', $langInstance);
        }
 
        /**
        }
 
        /**
@@ -1071,6 +1086,28 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        public final function getControllerInstance () {
                return $this->controllerInstance;
        }
        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]
 }
 
 // [EOF]