Permalink
Browse files

[FrameworkBundle] recursively resolve container parameter placeholders

for arrays in router _defaults
  • Loading branch information...
1 parent 9f157a1 commit 4b867654c637841934e68a086ea77474884c7a37 @docteurklein docteurklein committed Jul 20, 2012
@@ -114,6 +114,14 @@ private function resolveString($value)
{
$container = $this->container;
+ if (is_array($value)) {
+ foreach ($value as $key => $val) {
+ $value[$key] = $this->resolveString($val);
+ }
+
+ return $value;
+ }
+
if (null === $value || false === $value || true === $value || is_object($value)) {
return $value;
}
@@ -27,6 +27,8 @@ public function testDefaultsPlaceholders()
'foo' => 'before_%parameter.foo%',
'bar' => '%parameter.bar%_after',
'baz' => '%%unescaped%%',
+ 'boo' => array('%parameter%', '%%escaped_parameter%%', array('%bee_parameter%', 'bee')),
+ 'bee' => array('bee', 'bee'),
),
array(
)
@@ -39,6 +41,12 @@ public function testDefaultsPlaceholders()
$sc->expects($this->at(3))->method('hasParameter')->will($this->returnValue(true));
$sc->expects($this->at(4))->method('getParameter')->will($this->returnValue('bar'));
+ $sc->expects($this->at(5))->method('hasParameter')->will($this->returnValue(true));
+ $sc->expects($this->at(6))->method('getParameter')->will($this->returnValue('boo'));
+
+ $sc->expects($this->at(7))->method('hasParameter')->will($this->returnValue(true));
+ $sc->expects($this->at(8))->method('getParameter')->will($this->returnValue('foo_bee'));
+
$router = new Router($sc, 'foo');
$route = $router->getRouteCollection()->get('foo');
@@ -47,6 +55,8 @@ public function testDefaultsPlaceholders()
'foo' => 'before_foo',
'bar' => 'bar_after',
'baz' => '%unescaped%',
+ 'boo' => array('boo', '%escaped_parameter%', array('foo_bee', 'bee')),
+ 'bee' => array('bee', 'bee'),
),
$route->getDefaults()
);

0 comments on commit 4b86765

Please sign in to comment.