@@ -144,6 +144,14 @@ public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslO
144
144
*/
145
145
public function setValue ($ macro , $ replace , $ limit = self ::MAXIMUM_REPLACEMENTS_DEFAULT )
146
146
{
147
+ if (substr ($ macro , 0 , 2 ) !== '${ ' && substr ($ macro , -1 ) !== '} ' ) {
148
+ $ macro = '${ ' . $ macro . '} ' ;
149
+ }
150
+
151
+ if (!String::isUTF8 ($ replace )) {
152
+ $ replace = utf8_encode ($ replace );
153
+ }
154
+
147
155
foreach ($ this ->tempDocumentHeaders as $ index => $ headerXML ) {
148
156
$ this ->tempDocumentHeaders [$ index ] = $ this ->setValueForPart ($ this ->tempDocumentHeaders [$ index ], $ macro , $ replace , $ limit );
149
157
}
@@ -399,14 +407,6 @@ function ($match) {
399
407
*/
400
408
protected function setValueForPart ($ documentPartXML , $ search , $ replace , $ limit )
401
409
{
402
- if (substr ($ search , 0 , 2 ) !== '${ ' && substr ($ search , -1 ) !== '} ' ) {
403
- $ search = '${ ' . $ search . '} ' ;
404
- }
405
-
406
- if (!String::isUTF8 ($ replace )) {
407
- $ replace = utf8_encode ($ replace );
408
- }
409
-
410
410
// Note: we can't use the same function for both cases here, because of performance considerations.
411
411
if (self ::MAXIMUM_REPLACEMENTS_DEFAULT === $ limit ) {
412
412
return str_replace ($ search , $ replace , $ documentPartXML );
0 commit comments