Added new exception code (please cleanup others!).
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
index 09d13a5786c2faae223e49a2559654226ae28587..01a280da02ee32b936ceec5632c492c303ae986e 100644 (file)
@@ -3,11 +3,11 @@
  * The simulator system class is the super class of all other classes. This
  * class handles saving of games etc.
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -249,6 +249,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const EXCEPTION_ARRAY_ELEMENTS_MISSING       = 0x02c;
        const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED  = 0x02d;
        const EXCEPTION_UNSPPORTED_OPERATION         = 0x02e;
+       const EXCEPTION_FACTORY_REQUIRE_PARAMETER    = 0x02f;
        const EXCEPTION_MISSING_ELEMENT              = 0x030;
        const EXCEPTION_HEADERS_ALREADY_SENT         = 0x031;
        const EXCEPTION_DEFAULT_CONTROLLER_GONE      = 0x032;
@@ -259,7 +260,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_FILTER_CHAIN_INTERCEPTED     = 0x040;
+       const EXCEPTION_FILTER_CHAIN_INTERCEPTED     = 0x03a;
 
        /**
         * Hexadecimal->Decimal translation array
@@ -326,10 +327,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        $this->setConfigInstance(FrameworkConfiguration::getSelfInstance());
                } // END - if
 
-               // Is the startup time set? (0 cannot be true anymore)
+               // Is the startup time set? (0 cannot be TRUE anymore)
                if (self::$startupTime == 0) {
                        // Then set it
-                       self::$startupTime = microtime(true);
+                       self::$startupTime = microtime(TRUE);
                } // END - if
        }
 
@@ -355,6 +356,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                } else {
                        // Do not call this twice
                        trigger_error(__METHOD__ . ': Called twice.');
+                       exit;
                }
        }
 
@@ -404,11 +406,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                        // .. or size if array
                                        $argsString .= ', ' . count($arg);
                                } elseif ($arg === TRUE) {
-                                       // ... is boolean 'true'
-                                       $argsString .= ', true';
+                                       // ... is boolean 'TRUE'
+                                       $argsString .= ', TRUE';
                                } elseif ($arg === FALSE) {
-                                       // ... is boolean 'true'
-                                       $argsString .= ', false';
+                                       // ... is boolean 'FALSE'
+                                       $argsString .= ', FALSE';
                                }
 
                                // Closing bracket
@@ -426,7 +428,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 
                // Output stub message
                // @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class
-               self::createDebugInstance(__CLASS__)->debugOutput(sprintf("[unknown::%s:] Stub! Args: %s",
+               self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s',
                        $methodName,
                        $argsString
                ));
@@ -452,7 +454,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      void
         */
        public final function __set ($name, $value) {
-               $this->debugBackTrace(sprintf("Tried to set a missing field. name=%s, value[%s]=%s",
+               $this->debugBackTrace(sprintf('Tried to set a missing field. name=%s, value[%s]=%s',
                        $name,
                        gettype($value),
                        $value
@@ -466,7 +468,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      void
         */
        public final function __get ($name) {
-               $this->debugBackTrace(sprintf("Tried to get a missing field. name=%s",
+               $this->debugBackTrace(sprintf('Tried to get a missing field. name=%s',
                        $name
                ));
        }
@@ -478,7 +480,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      void
         */
        public final function __unset ($name) {
-               $this->debugBackTrace(sprintf("Tried to unset a missing field. name=%s",
+               $this->debugBackTrace(sprintf('Tried to unset a missing field. name=%s',
                        $name
                ));
        }
@@ -1337,20 +1339,20 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Is a message set?
                if (!empty($message)) {
                        // Construct message
-                       $content = sprintf("<div class=\"debug_message\">Message: %s</div>\n", $message);
+                       $content = sprintf('<div class="debug_message">Message: %s</div>' . PHP_EOL, $message);
                } // END - if
 
                // Generate the output
-               $content .= sprintf("<pre>%s</pre>",
+               $content .= sprintf('<pre>%s</pre>',
                        trim(
                                htmlentities(
-                                       print_r($this, true)
+                                       print_r($this, TRUE)
                                )
                        )
                );
 
                // Output it
-               ApplicationEntryPoint::app_exit(sprintf("<div class=\"debug_header\">%s debug output:</div><div class=\"debug_content\">%s</div>\nLoaded includes: <div class=\"debug_include_list\">%s</div>",
+               ApplicationEntryPoint::app_exit(sprintf('<div class="debug_header">%s debug output:</div><div class="debug_content">%s</div>Loaded includes: <div class="debug_include_list">%s</div>',
                        $this->__toString(),
                        $content,
                        ClassLoader::getSelfInstance()->getPrintableIncludeList()
@@ -1410,6 +1412,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                } else {
                        // Trigger an error
                        trigger_error($stubMessage);
+                       exit;
                }
        }
 
@@ -1417,7 +1420,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * Outputs a debug backtrace and stops further script execution
         *
         * @param       $message        An optional message to output
-        * @param       $doExit         Whether exit the program (true is default)
+        * @param       $doExit         Whether exit the program (TRUE is default)
         * @return      void
         */
        public function debugBackTrace ($message = '', $doExit = TRUE) {
@@ -1444,25 +1447,45 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $debugInstance  An instance of a debugger class
         */
        public final static function createDebugInstance ($className) {
-               // Init debug instance
-               $debugInstance = NULL;
+               // Is the instance set?
+               if (!Registry::getRegistry()->instanceExists('debug')) {
+                       // Init debug instance
+                       $debugInstance = NULL;
+
+                       // Try it
+                       try {
+                               // Get a debugger instance
+                               $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class'));
+                       } catch (NullPointerException $e) {
+                               // Didn't work, no instance there
+                               exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
+                       }
 
-               // Try it
-               try {
-                       // Get a debugger instance
-                       $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class'));
-               } catch (NullPointerException $e) {
-                       // Didn't work, no instance there
-                       exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
-               }
+                       // Empty string should be ignored and used for testing the middleware
+                       DebugMiddleware::getSelfInstance()->output('');
 
-               // Empty string should be ignored and used for testing the middleware
-               DebugMiddleware::getSelfInstance()->output('');
+                       // Set it in its own class. This will set it in the registry
+                       $debugInstance->setDebugInstance($debugInstance);
+               } else {
+                       // Get instance from registry
+                       $debugInstance = Registry::getRegistry()->getDebugInstance();
+               }
 
                // Return it
                return $debugInstance;
        }
 
+       /**
+        * Simple output of a message with line-break
+        *
+        * @param       $message        Message to output
+        * @return      void
+        */
+       public function outputLine ($message) {
+               // Simply output it
+               print($message . PHP_EOL);
+       }
+
        /**
         * Outputs a debug message whether to debug instance (should be set!) or
         * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
@@ -1470,7 +1493,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         *
         * @param       $message        Message we shall send out...
         * @param       $doPrint        Whether print or die here (default: print)
-        * @paran       $stripTags      Whether to strip tags (default: false)
+        * @paran       $stripTags      Whether to strip tags (default: FALSE)
         * @return      void
         */
        public function debugOutput ($message, $doPrint = TRUE, $stripTags = FALSE) {
@@ -1504,7 +1527,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        // Put directly out
                        if ($doPrint === TRUE) {
                                // Print message
-                               print($message . chr(10));
+                               $this->outputLine($message);
                        } else {
                                // Die here
                                exit($message);
@@ -1707,7 +1730,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 
                // Get current array
                $fieldArray = $resultInstance->current();
-               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, true).'</pre>');
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, TRUE).'</pre>');
 
                // Convert dashes to underscore
                $fieldName = $this->convertDashesToUnderscores($fieldName);
@@ -1764,6 +1787,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        } else {
                                // Trigger an error
                                trigger_error($message . "<br />\n");
+                               exit;
                        }
                } else {
                        // @TODO Finish this part!
@@ -1793,7 +1817,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        public function getMilliTime () {
                // Get the time of day as float
-               $milliTime = gettimeofday(true);
+               $milliTime = gettimeofday(TRUE);
 
                // Return it
                return $milliTime;
@@ -1972,7 +1996,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        protected function isBase64Encoded ($encodedData) {
                // Determine it
-               $isBase64 = (@base64_decode($encodedData, true) !== FALSE);
+               $isBase64 = (@base64_decode($encodedData, TRUE) !== FALSE);
 
                // Return it
                return $isBase64;
@@ -2006,7 +2030,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = array()) {
                // Generate it
-               $cacheKey = sprintf("%s@%s",
+               $cacheKey = sprintf('%s@%s',
                        $this->__toString(),
                        $criteriaInstance->getCacheKey($onlyKeys)
                );
@@ -2032,7 +2056,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        protected function getPrintableExecutionTime () {
                // Caculate the execution time
-               $executionTime = microtime(true) - $this->getStartupTime();
+               $executionTime = microtime(TRUE) - $this->getStartupTime();
 
                // Pack it in nice braces
                $executionTime = sprintf('[ %01.5f ] ', $executionTime);
@@ -2119,38 +2143,44 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
-        * Determines if a key is set in the generic array
+        * Determines if an element is set in the generic array
         *
         * @param       $keyGroup       Main group for the key
         * @param       $subGroup       Sub group for the key
         * @param       $key            Key to check
+        * @param       $element        Element to check
         * @return      $isset          Whether the given key is set
         */
-       protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
+       protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
+
                // Is it there?
-               $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
+               $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
 
                // Return it
                return $isset;
        }
-
        /**
-        * Determines if an element is set in the generic array
+        * Determines if a key is set in the generic array
         *
         * @param       $keyGroup       Main group for the key
         * @param       $subGroup       Sub group for the key
         * @param       $key            Key to check
-        * @param       $element        Element to check
         * @return      $isset          Whether the given key is set
         */
-       protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
+       protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
+
                // Is it there?
-               $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
+               $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
 
                // Return it
                return $isset;
        }
 
+
        /**
         * Determines if a group is set in the generic array
         *
@@ -2159,6 +2189,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $isset          Whether the given group is set
         */
        protected final function isGenericArrayGroupSet ($keyGroup, $subGroup) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
+
                // Is it there?
                $isset = isset($this->genericArray[$keyGroup][$subGroup]);
 
@@ -2178,8 +2211,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
                        // No, then abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
+                       exit;
                } // END - if
 
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], TRUE));
+
                // Return it
                return $this->genericArray[$keyGroup][$subGroup];
        }
@@ -2192,11 +2229,31 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @param       $key            Key to unset
         * @return      void
         */
-       protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key) {
+       protected final function unsetGenericArrayKey ($keyGroup, $subGroup, $key) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
+
                // Remove it
                unset($this->genericArray[$keyGroup][$subGroup][$key]);
        }
 
+       /**
+        * Unsets a given element in generic array
+        *
+        * @param       $keyGroup       Main group for the key
+        * @param       $subGroup       Sub group for the key
+        * @param       $key            Key to unset
+        * @param       $element        Element to unset
+        * @return      void
+        */
+       protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
+
+               // Remove it
+               unset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
+       }
+
        /**
         * Append a string to a given generic array key
         *
@@ -2206,7 +2263,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @param       $value          Value to add/append
         * @return      void
         */
-       protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $value, $appendGlue = '') {
+       protected final function appendStringToGenericArrayKey ($keyGroup, $subGroup, $key, $value, $appendGlue = '') {
+               // Debug message
+               //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue);
+
                // Is it already there?
                if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
                        // Append it
@@ -2218,24 +2278,102 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
-        * Initializes given generic array
+        * Append a string to a given generic array element
+        *
+        * @param       $keyGroup       Main group for the key
+        * @param       $subGroup       Sub group for the key
+        * @param       $key            Key to unset
+        * @param       $element        Element to check
+        * @param       $value          Value to add/append
+        * @return      void
+        */
+       protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') {
+               // Debug message
+               //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue);
+
+               // Is it already there?
+               if ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
+                       // Append it
+                       $this->genericArray[$keyGroup][$subGroup][$key][$element] .= $appendGlue . (string) $value;
+               } else {
+                       // Add it
+                       $this->genericArray[$keyGroup][$subGroup][$key][$element] = (string) $value;
+               }
+       }
+
+       /**
+        * Initializes given generic array group
         *
         * @param       $keyGroup       Main group for the key
         * @param       $subGroup       Sub group for the key
         * @param       $key            Key to use
+        * @param       $forceInit      Optionally force initialization
         * @return      void
         */
-       protected final function initGenericArray ($keyGroup, $subGroup, $key) {
+       protected final function initGenericArrayGroup ($keyGroup, $subGroup, $forceInit = FALSE) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',forceInit=' . intval($forceInit));
+
                // Is it already set?
-               if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+               if (($forceInit === FALSE) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) {
+                       // Already initialized
+                       trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.');
+                       exit;
+               } // END - if
+
+               // Initialize it
+               $this->genericArray[$keyGroup][$subGroup] = array();
+       }
+
+       /**
+        * Initializes given generic array key
+        *
+        * @param       $keyGroup       Main group for the key
+        * @param       $subGroup       Sub group for the key
+        * @param       $key            Key to use
+        * @param       $forceInit      Optionally force initialization
+        * @return      void
+        */
+       protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = FALSE) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',forceInit=' . intval($forceInit));
+
+               // Is it already set?
+               if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
                        // Already initialized
                        trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.');
+                       exit;
                } // END - if
 
                // Initialize it
                $this->genericArray[$keyGroup][$subGroup][$key] = array();
        }
 
+       /**
+        * Initializes given generic array element
+        *
+        * @param       $keyGroup       Main group for the key
+        * @param       $subGroup       Sub group for the key
+        * @param       $key            Key to use
+        * @param       $element        Element to use
+        * @param       $forceInit      Optionally force initialization
+        * @return      void
+        */
+       protected final function initGenericArrayElement ($keyGroup, $subGroup, $key, $element, $forceInit = FALSE) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',forceInit=' . intval($forceInit));
+
+               // Is it already set?
+               if (($forceInit === FALSE) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) {
+                       // Already initialized
+                       trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.');
+                       exit;
+               } // END - if
+
+               // Initialize it
+               $this->genericArray[$keyGroup][$subGroup][$key][$element] = array();
+       }
+
        /**
         * Pushes an element to a generic key
         *
@@ -2245,15 +2383,17 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @param       $value          Value to add/append
         * @return      $count          Number of array elements
         */
-       protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $value) {
+       protected final function pushValueToGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
+               // Debug message
+               //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
+
                // Is it set?
                if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
                        // Initialize array
-                       $this->initGenericArray($keyGroup, $subGroup, $key);
+                       $this->initGenericArrayKey($keyGroup, $subGroup, $key);
                } // END - if
 
                // Then push it
-               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value=' . $value . PHP_EOL);
                $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value);
 
                // Return count
@@ -2262,6 +2402,35 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $count;
        }
 
+       /**
+        * Pushes an element to a generic array element
+        *
+        * @param       $keyGroup       Main group for the key
+        * @param       $subGroup       Sub group for the key
+        * @param       $key            Key to use
+        * @param       $element        Element to check
+        * @param       $value          Value to add/append
+        * @return      $count          Number of array elements
+        */
+       protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
+               // Debug message
+               //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
+
+               // Is it set?
+               if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
+                       // Initialize array
+                       $this->initGenericArrayElement($keyGroup, $subGroup, $key, $element);
+               } // END - if
+
+               // Then push it
+               $count = array_push($this->genericArray[$keyGroup][$subGroup][$key][$element], $value);
+
+               // Return count
+               //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
+               //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL);
+               return $count;
+       }
+
        /**
         * Pops an element from  a generic group
         *
@@ -2271,19 +2440,22 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $value          Last "popped" value
         */
        protected final function popGenericArrayElement ($keyGroup, $subGroup, $key) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
+
                // Is it set?
                if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
                        // Not found
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
+                       exit;
                } // END - if
 
                // Then "pop" it
-               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' pop-ing entry ...' . PHP_EOL);
                $value = array_pop($this->genericArray[$keyGroup][$subGroup][$key]);
 
                // Return value
                //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
-               //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . $value . PHP_EOL);
+               //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
                return $value;
        }
 
@@ -2296,19 +2468,22 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $value          Last "popped" value
         */
        protected final function shiftGenericArrayElement ($keyGroup, $subGroup, $key) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
+
                // Is it set?
                if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
                        // Not found
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
+                       exit;
                } // END - if
 
                // Then "shift" it
-               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' shifting entry ...' . PHP_EOL);
                $value = array_shift($this->genericArray[$keyGroup][$subGroup][$key]);
 
                // Return value
                //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
-               //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . $value . PHP_EOL);
+               //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
                return $value;
        }
 
@@ -2319,15 +2494,22 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $count          Count of given group
         */
        protected final function countGenericArray ($keyGroup) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup);
+
                // Is it there?
                if (!isset($this->genericArray[$keyGroup])) {
                        // Abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.');
+                       exit;
                } // END - if
 
                // Then count it
                $count = count($this->genericArray[$keyGroup]);
 
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',count=' . $count);
+
                // Return it
                return $count;
        }
@@ -2340,15 +2522,22 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $count          Count of given group
         */
        protected final function countGenericArrayGroup ($keyGroup, $subGroup) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
+
                // Is it there?
                if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
                        // Abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
+                       exit;
                } // END - if
 
                // Then count it
                $count = count($this->genericArray[$keyGroup][$subGroup]);
 
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',count=' . $count);
+
                // Return it
                return $count;
        }
@@ -2362,18 +2551,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $count          Count of given key
         */
        protected final function countGenericArrayElements ($keyGroup, $subGroup, $key) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
+
                // Is it there?
                if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
                        // Abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
+                       exit;
                } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) {
                        // Not valid
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' is not an array.');
+                       exit;
                }
 
                // Then count it
                $count = count($this->genericArray[$keyGroup][$subGroup][$key]);
-               //* DEBUG: */ print(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',count=' . $count . PHP_EOL);
+
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',count=' . $count);
 
                // Return it
                return $count;
@@ -2386,10 +2582,14 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $array          Whole generic array group
         */
        protected final function getGenericArray ($keyGroup) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup);
+
                // Is it there?
                if (!isset($this->genericArray[$keyGroup])) {
                        // Then abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.');
+                       exit;
                } // END - if
 
                // Return it
@@ -2406,6 +2606,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      void
         */
        protected final function setGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
+               // Debug message
+               //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
+
                // Set value here
                $this->genericArray[$keyGroup][$subGroup][$key] = $value;
        }
@@ -2419,10 +2622,14 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $value          Mixed value from generic array element
         */
        protected final function getGenericArrayKey ($keyGroup, $subGroup, $key) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
+
                // Is it there?
                if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
                        // Then abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.');
+                       exit;
                } // END - if
 
                // Return it
@@ -2440,6 +2647,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      void
         */
        protected final function setGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
+               // Debug message
+               //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
+
                // Then set it
                $this->genericArray[$keyGroup][$subGroup][$key][$element] = $value;
        }
@@ -2454,10 +2664,14 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $value          Mixed value from generic array element
         */
        protected final function getGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
+
                // Is it there?
                if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
                        // Then abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.');
+                       exit;
                } // END - if
 
                // Return it
@@ -2472,12 +2686,34 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $isValid        Whether given sub group is valid
         */
        protected final function isValidGenericArrayGroup ($keyGroup, $subGroup) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
+
                // Determine it
                $isValid = (($this->isGenericArrayGroupSet($keyGroup, $subGroup)) && (is_array($this->getGenericSubArray($keyGroup, $subGroup))));
 
                // Return it
                return $isValid;
        }
+
+       /**
+        * Checks if a given key is valid (array)
+        *
+        * @param       $keyGroup       Key group to get
+        * @param       $subGroup       Sub group for the key
+        * @param       $key            Key to check
+        * @return      $isValid        Whether given sub group is valid
+        */
+       protected final function isValidGenericArrayKey ($keyGroup, $subGroup, $key) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
+
+               // Determine it
+               $isValid = (($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) && (is_array($this->getGenericArrayKey($keyGroup, $subGroup, $key))));
+
+               // Return it
+               return $isValid;
+       }
 }
 
 // [EOF]