@@ -88,44 +88,45 @@ private function resolveParameters(RouteCollection $collection)
88
88
$ this ->resolveParameters ($ route );
89
89
} else {
90
90
foreach ($ route ->getDefaults () as $ name => $ value ) {
91
- $ route ->setDefault ($ name , $ this ->resolveString ($ value ));
91
+ $ route ->setDefault ($ name , $ this ->resolve ($ value ));
92
92
}
93
93
94
94
foreach ($ route ->getRequirements () as $ name => $ value ) {
95
- $ route ->setRequirement ($ name , $ this ->resolveString ($ value ));
95
+ $ route ->setRequirement ($ name , $ this ->resolve ($ value ));
96
96
}
97
97
98
- $ route ->setPattern ($ this ->resolveString ($ route ->getPattern ()));
98
+ $ route ->setPattern ($ this ->resolve ($ route ->getPattern ()));
99
99
}
100
100
}
101
101
}
102
102
103
103
/**
104
- * Replaces placeholders with the service container parameters in the given string .
104
+ * Recursively replaces placeholders with the service container parameters.
105
105
*
106
- * @param mixed $value The source string which might contain %placeholders%
106
+ * @param mixed $value The source which might contain " %placeholders%"
107
107
*
108
- * @return mixed A string where the placeholders have been replaced, or the original value if not a string.
108
+ * @return mixed The source with the placeholders replaced by the container
109
+ * parameters. Array are resolved recursively.
109
110
*
110
111
* @throws ParameterNotFoundException When a placeholder does not exist as a container parameter
111
112
* @throws RuntimeException When a container value is not a string or a numeric value
112
113
*/
113
- private function resolveString ($ value )
114
+ private function resolve ($ value )
114
115
{
115
- $ container = $ this ->container ;
116
-
117
116
if (is_array ($ value )) {
118
117
foreach ($ value as $ key => $ val ) {
119
- $ value [$ key ] = $ this ->resolveString ($ val );
118
+ $ value [$ key ] = $ this ->resolve ($ val );
120
119
}
121
120
122
121
return $ value ;
123
122
}
124
123
125
- if (null === $ value || false === $ value || true === $ value || is_object ($ value )) {
124
+ if (! is_string ($ value )) {
126
125
return $ value ;
127
126
}
128
127
128
+ $ container = $ this ->container ;
129
+
129
130
$ escapedValue = preg_replace_callback ('/%%|%([^%\s]+)%/ ' , function ($ match ) use ($ container , $ value ) {
130
131
// skip %%
131
132
if (!isset ($ match [1 ])) {
0 commit comments