Fixed the unescaping of parameters to handle arrays

This commit is contained in:
Christophe Coevoet 2012-02-02 18:26:12 +01:00
parent 045f936038
commit 8e13095e5c

View File

@ -139,7 +139,7 @@ class ParameterBag implements ParameterBagInterface
foreach ($this->parameters as $key => $value) { foreach ($this->parameters as $key => $value) {
try { try {
$value = $this->resolveValue($value); $value = $this->resolveValue($value);
$parameters[$key] = is_string($value) ? str_replace('%%', '%', $value) : $value; $parameters[$key] = $this->unescapeString($value);
} catch (ParameterNotFoundException $e) { } catch (ParameterNotFoundException $e) {
$e->setSourceKey($key); $e->setSourceKey($key);
@ -235,4 +235,22 @@ class ParameterBag implements ParameterBagInterface
{ {
return $this->resolved; return $this->resolved;
} }
private function unescapeString($value)
{
if (is_string($value)) {
return str_replace('%%', '%', $value);
}
if (is_array($value)) {
$result = array();
foreach ($value as $k => $v) {
$result[$k] = $this->unescapeString($v);
}
return $result;
}
return $value;
}
} }