Fixed more generic array handling, introduced unsetGenericArrayKey()
authorRoland Häder <roland@mxchange.org>
Fri, 28 Jun 2013 22:04:57 +0000 (22:04 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 28 Jun 2013 22:04:57 +0000 (22:04 +0000)
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/criteria/class_BaseCriteria.php
inc/classes/main/stacker/class_BaseStacker.php

index 0fb474dcb865fafa32ceb60749b6428817b2439b..62b79bda0d49440bd0827c1d076fd0ff5a8312e3 100644 (file)
@@ -2193,12 +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
         *
@@ -2228,7 +2243,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @param       $forceInit      Optionally force initialization
         * @return      void
         */
-       protected final function initGenericArray ($keyGroup, $subGroup, $key, $forceInit = FALSE) {
+       protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = FALSE) {
                // Is it already set?
                if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
                        // Already initialized
@@ -2253,7 +2268,7 @@ 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
index aa8a401b7afe9d7e2cc49b5cf5d6e2164030fe94..7ba2ea57aafe807744615af8b016f8774a5bfa06 100644 (file)
@@ -36,6 +36,12 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
        protected function __construct ($className) {
                // Call parent constructor
                parent::__construct($className);
+
+               // Initialize all criteria arrays
+               foreach (array('default', 'choice', 'exclude') as $criteriaType) {
+                       // Init it
+                       $this->initGenericArrayKey('criteria', $criteriaType, 'entries');
+               } // END - foreach
        }
 
        /**
@@ -50,7 +56,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE));
 
                // Determine it
-               $isSet = $this->isGenericArrayKeySet('criteria', $criteriaType, $criteriaKey);
+               $isSet = $this->isGenericArrayElementSet('criteria', $criteriaType, 'entries', $criteriaKey);
 
                // Return it
                return $isSet;
@@ -104,7 +110,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
         * @return      $criteria
         */
        public final function getCriteriaArray ($criteriaType = 'default') {
-               return $this->getGenericSubArray('criteria', $criteriaType);
+               return $this->getGenericArrayKey('criteria', $criteriaType, 'entries');
        }
 
        /**
@@ -141,7 +147,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                // "Walk" through all criterias
                foreach ($this->getGenericArray('criteria') as $criteriaType => $dummy) {
                        // Remove it
-                       $this->unsetGenericArrayElement('criteria', $criteriaType, $criteriaKey);
+                       $this->unsetGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey);
                } // END - foreach
        }
 
index aaa1adcae20770e9d667c16eb5e757a8a08bd87f..a3419fe486db58647b1463e2b3eea823e44180db 100644 (file)
@@ -55,7 +55,7 @@ class BaseStacker extends BaseFrameworkSystem {
                } // END - if
 
                // Initialize the given stack
-               $this->initGenericArray('stacks', $stackerName, 'entries', $forceReInit);
+               $this->initGenericArrayKey('stacks', $stackerName, 'entries', $forceReInit);
        }
 
        /**