Hello,
Thanks for your feedback. The current code of the testing branch of that method in BulkProcessing is the following:
protected function variable2Text($variables, $dom, $options)
{
if (PHP_VERSION_ID < 80000) {
$optionEntityLoader = libxml_disable_entity_loader(true);
}
$dom = simplexml_load_string($dom->saveXML());
if (PHP_VERSION_ID < 80000) {
libxml_disable_entity_loader($optionEntityLoader);
}
$dom->registerXPathNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
if (isset($options['firstMatch'])) {
$firstMatch = $options['firstMatch'];
} else {
$firstMatch = false;
}
foreach ($variables as $variable => $value) {
$search = $this->templateSymbolStart . $variable . $this->templateSymbolEnd;
$query = '//w:t[text()[contains(., "' . $search . '")]]';
if ($firstMatch) {
$query = '(' . $query . ')[1]';
}
$foundNodes = $dom->xpath($query);
foreach ($foundNodes as $node) {
$strNode = (string) $node;
if ($options['parseLineBreaks']) {
// replace line breaks
$value = str_replace(array('\n\r', '\r\n', '\n', '\r', "\n\r", "\r\n", "\n", "\r"), '__LINEBREAK__', $value);
}
$strNode = str_replace($search, $value, $strNode);
$node[0] = $strNode;
}
}
return $dom;
}
to avoid reloading the DOM content for each variable.
Regards.