* Search for a variable in the stack
*
* @param $variableName The variable we are looking for
- * @param $stack Optional variable stack to look in
+ * @param $variableGroup Optional variable group to look in
* @return $index FALSE means not found, >=0 means found on a specific index
*/
- private function getVariableIndex ($variableName, $stack = NULL) {
+ private function getVariableIndex ($variableName, $variableGroup = NULL) {
// Replace all dashes to underscores to match variables with configuration entries
$variableName = trim($this->convertDashesToUnderscores($variableName));
$found = false;
// If the stack is null, use the current group
- if (is_null($stack)) {
+ if (is_null($variableGroup)) {
// Use current group
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
- $stack = $this->currGroup;
+ $variableGroup = $this->currGroup;
} // END - if
// Is the group there?
- if ($this->isVarStackSet($stack)) {
+ if ($this->isVarStackSet($variableGroup)) {
// Now search for it
- foreach ($this->getVarStack($stack) as $index => $currEntry) {
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':currGroup=' . $stack . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName);
+ foreach ($this->getVarStack($variableGroup) as $index => $currEntry) {
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':currGroup=' . $variableGroup . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName);
// Is the entry found?
if ($currEntry['name'] == $variableName) {
// Found!
}
/**
- * Checks whether the given variable stack is set
+ * Checks whether the given variable group is set
*
- * @param $stack Variable stack to check
- * @return $isSet Whether the given variable stack is set
+ * @param $variableGroup Variable group to check
+ * @return $isSet Whether the given variable group is set
*/
- protected final function isVarStackSet ($stack) {
+ protected final function isVarStackSet ($variableGroup) {
// Check it
- $isSet = isset($this->varStack[$stack]);
+ $isSet = isset($this->varStack[$variableGroup]);
// Return result
return $isSet;
}
/**
- * Getter for given variable stack
+ * Getter for given variable group
*
- * @param $stack Variable stack to check
- * @return $varStack Found variable stack
+ * @param $variableGroup Variable group to check
+ * @return $varStack Found variable group
*/
- public final function getVarStack ($stack) {
- return $this->varStack[$stack];
+ public final function getVarStack ($variableGroup) {
+ return $this->varStack[$variableGroup];
}
/**
- * Setter for given variable stack
+ * Setter for given variable group
*
- * @param $stack Variable stack to check
- * @param $varStack Variable stack to check
+ * @param $variableGroup Variable group to check
+ * @param $varStack Variable stack to check
* @return void
*/
- protected final function setVarStack ($stack, array $varStack) {
- $this->varStack[$stack] = $varStack;
+ protected final function setVarStack ($variableGroup, array $varStack) {
+ $this->varStack[$variableGroup] = $varStack;
}
/**
* Return a content of a variable or null if not found
*
* @param $variableName The variable we are looking for
- * @param $stack Optional variable stack to look in
+ * @param $variableGroup Optional variable group to look in
* @return $content Content of the variable or null if not found
*/
- protected function readVariable ($variableName, $stack = NULL) {
+ protected function readVariable ($variableName, $variableGroup = NULL) {
// Replace all dashes to underscores to match variables with configuration entries
$variableName = trim($this->convertDashesToUnderscores($variableName));
$content = NULL;
// If the stack is null, use the current group
- if (is_null($stack)) {
+ if (is_null($variableGroup)) {
// Use current group
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
- $stack = $this->currGroup;
+ $variableGroup = $this->currGroup;
} // END - if
// Get variable index
- $found = $this->getVariableIndex($variableName, $stack);
+ $found = $this->getVariableIndex($variableName, $variableGroup);
// Is the variable found?
if ($found !== false) {
// Read it
- $content = $this->getVariableValue($stack, $found);
+ $content = $this->getVariableValue($variableGroup, $found);
} // END - if
// Return the current position
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': group=' . $stack . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': variableGroup=' . $variableGroup . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content);
return $content;
}
/**
* Add a variable to the stack
*
- * @param $variableName The variable we are looking for
- * @param $value The value we want to store in the variable
+ * @param $variableName Name of variable to add
+ * @param $value Value we want to store in the variable
* @return void
*/
private function addVariable ($variableName, $value) {
* Removes a given variable
*
* @param $variableName The variable we are looking for
+ * @param $variableGroup Name of variable group (default: 'general')
* @return void
*/
- public final function removeVariable ($variableName) {
+ public final function removeVariable ($variableName, $variableGroup = 'general') {
// First search for the variable if it was already added
- $index = $this->getVariableIndex($variableName);
+ $index = $this->getVariableIndex($variableName, $variableGroup);
// Was it found?
if ($index !== false) {
// Remove this variable
- $this->unsetVariableStackOffset($index);
+ $this->unsetVariableStackOffset($index, $variableGroup);
} // END - if
}
/**
- * Unsets the given offset in the variable stack
+ * Unsets the given offset in the variable group
*
- * @param $index Index to unset
+ * @param $index Index to unset
+ * @param $variableGroup Variable group (default: currGroup)
* @return void
*/
- protected final function unsetVariableStackOffset ($index) {
+ protected final function unsetVariableStackOffset ($index, $variableGroup = NULL) {
+ // Is the variable group not set?
+ if (is_null($variableGroup)) {
+ // Then set it to current
+ $variableGroup = $this->currGroup;
+ } // END - if
+
// Is the entry there?
- if (!isset($this->varStack[$this->currGroup][$index])) {
+ if (!isset($this->varStack[$variableGroup][$index])) {
// Abort here, we need fixing!
$this->debugInstance();
} // END - if
// Remove it
- unset($this->varStack[$this->currGroup][$index]);
+ unset($this->varStack[$variableGroup][$index]);
}
/**
/**
* Compiles configuration place-holders in all variables. This 'walks'
- * through the variable stack 'general'. It interprets all values from that
+ * through the variable group 'general'. It interprets all values from that
* variables as configuration entries after compiling them.
*
* @return void