Skip to content
Snippets Groups Projects
Commit 6b04b7d4 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add support for multidimentional array in assign & replaceVars routines

parent aabad941
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,7 @@ class VariableReplacer { ...@@ -53,7 +53,7 @@ class VariableReplacer {
$this->objects[$var] = $val; $this->objects[$var] = $val;
} elseif($var && is_array($var)) { } elseif($var && is_array($var)) {
foreach($var as $k => $v) foreach($var as $k => $v)
$this->variables[$k] = $v; //NOT calling assign to force one dimentional array. $this->assign($k, $v);
} elseif($var) { } elseif($var) {
$this->variables[$var] = $val; $this->variables[$var] = $val;
} }
...@@ -90,12 +90,15 @@ class VariableReplacer { ...@@ -90,12 +90,15 @@ class VariableReplacer {
return $this->getVar($rv, $part); return $this->getVar($rv, $part);
} }
function replaceVars($text) { function replaceVars($input) {
if(!($vars=$this->_parse($text))) if($input && is_array($input))
return $text; return array_map(array($this, 'replaceVars'), $input);
return preg_replace($this->_delimit(array_keys($vars)), array_values($vars), $text); if(!($vars=$this->_parse($input)))
return $input;
return preg_replace($this->_delimit(array_keys($vars)), array_values($vars), $input);
} }
function _resolveVar($var) { function _resolveVar($var) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment