@@ -144,6 +144,14 @@ public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslO
144144 */
145145 public function setValue ($ macro , $ replace , $ limit = self ::MAXIMUM_REPLACEMENTS_DEFAULT )
146146 {
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+
147155 foreach ($ this ->tempDocumentHeaders as $ index => $ headerXML ) {
148156 $ this ->tempDocumentHeaders [$ index ] = $ this ->setValueForPart ($ this ->tempDocumentHeaders [$ index ], $ macro , $ replace , $ limit );
149157 }
@@ -399,14 +407,6 @@ function ($match) {
399407 */
400408 protected function setValueForPart ($ documentPartXML , $ search , $ replace , $ limit )
401409 {
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-
410410 // Note: we can't use the same function for both cases here, because of performance considerations.
411411 if (self ::MAXIMUM_REPLACEMENTS_DEFAULT === $ limit ) {
412412 return str_replace ($ search , $ replace , $ documentPartXML );
0 commit comments