]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
Fixed more generic array handling, introduced unsetGenericArrayKey()
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
index 80d861d333f7c7eec27a7df3b9ef186ed4d6e8ea..62b79bda0d49440bd0827c1d076fd0ff5a8312e3 100644 (file)
@@ -2181,6 +2181,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                } // END - if
 
                // Return it
+               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' returning!' . PHP_EOL);
                return $this->genericArray[$keyGroup][$subGroup];
        }
 
@@ -2192,11 +2193,27 @@ 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) {
                // Remove it
+               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' unset!' . PHP_EOL);
                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) {
+               // Remove it
+               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' unset!' . PHP_EOL);
+               unset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
+       }
+
        /**
         * Append a string to a given generic array key
         *
@@ -2223,16 +2240,18 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @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 initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = FALSE) {
                // Is it already set?
-               if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+               if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
                        // Already initialized
                        trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.');
                } // END - if
 
                // Initialize it
+               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . PHP_EOL);
                $this->genericArray[$keyGroup][$subGroup][$key] = array();
        }
 
@@ -2249,11 +2268,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // 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);
+               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
                $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value);
 
                // Return count
@@ -2283,7 +2302,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 
                // 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;
        }