From: Roland Häder Date: Fri, 28 Jun 2013 22:04:57 +0000 (+0000) Subject: Fixed more generic array handling, introduced unsetGenericArrayKey() X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=01cc80f06529313b40cb6858eae3f361c8ed1aee Fixed more generic array handling, introduced unsetGenericArrayKey() --- diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 0fb474dc..62b79bda 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -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 diff --git a/inc/classes/main/criteria/class_BaseCriteria.php b/inc/classes/main/criteria/class_BaseCriteria.php index aa8a401b..7ba2ea57 100644 --- a/inc/classes/main/criteria/class_BaseCriteria.php +++ b/inc/classes/main/criteria/class_BaseCriteria.php @@ -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 } diff --git a/inc/classes/main/stacker/class_BaseStacker.php b/inc/classes/main/stacker/class_BaseStacker.php index aaa1adca..a3419fe4 100644 --- a/inc/classes/main/stacker/class_BaseStacker.php +++ b/inc/classes/main/stacker/class_BaseStacker.php @@ -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); } /**