Hello,
how can I intercept the warning generated by replaceVariableByText() when I try to replace a variable in the doc which does not exists?
Even if I surround with a try/catch, I still have the warning on stdout, and can't intercept it:
try {
$docx->replaceVariableByText(['inexistant'=>'...']);
} catch (Exception $e) {
echo $e->getMessage();
}
Warning: DOMDocument::loadXML(): ParsePI: PI xml0version space expected in Entity, line: 1 in vendor\phpdocx\classes\CreateDocxFromTemplate.inc on line 1943
Call Stack:
...
0.3291 18337616 5. CreateDocxFromTemplate->replaceVariableByText() myclass.class.php:4912
0.3291 18526032 6. CreateDocxFromTemplate->variable2Text() vendor\phpdocx\classes\CreateDocxFromTemplate.inc:1338
0.3291 18526032 7. CreateDocxFromTemplate->repairVariables() vendor\phpdocx\classes\CreateDocxFromTemplate.inc:2085
0.3310 18893696 8. DOMDocument->loadXML() vendor\phpdocx\classes\CreateDocxFromTemplate.inc:1943
Must I replace the logger by a custom behavior which throws exceptions, or something?
(Or is it a bug, as we should never have API internals warnings displayed?)
Best regards,