Issue Feature Closed

#20255helper function for handling with TYPOScript

Sebastian Böttger 03/30/09, 20:05 updated 09/09/13, 10:55

Description

in t3lib_div there should be a helper function for TYPOScript values.

The patch merges the following function into the core

/**
  • Helper function: slices a key from TYPOScript setup through different levels in an easy way
  • Example call: t3lib_div::getTSValue(‘key1.key2.key3’, $this->conf); => return value of key1.key2.key3
  • param string The path to find * param array a TYPOScript setup array
  • @return mixed array if given path is TO node, string if given path is TO leave, empty string if the given path is empty, false if the given path is not set

  • */
    public function getTSValue($path, $conf) {
    $subkeys = explode(‘.’,$path);
    $arr = $conf;
    $max = count($subkeys);
    for($i = 0; $i < $max; $i++) {
    $key = $subkeys[$i];
    if ($i < ($max – 1)) {
    $key .= ‘.’;
    }
       if (array_key_exists($key, $arr)) {
$arr = $arr[$key];
} else {
if (array_key_exists($key.’.’, $arr)) {
$arr = $arr[$key.’.’];
} else {
return false;
}
}
}
return $arr;
}
(issue imported from #M10812)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.