You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TemplateProcessor methods setComplexBlock and setComplexValue fail when attempting to use them on Sections. It is unclear whether this is by design or just an oversight.
Steps to Reproduce
Please provide a code sample that reproduces the issue.
<?phprequire__DIR__ . '/vendor/autoload.php';
usePhpOffice\PhpWord\Element\Section;
usePhpOffice\PhpWord\Element\TextRun;
usePhpOffice\PhpWord\Shared\Html;
usePhpOffice\PhpWord\TemplateProcessor;
$templateProcessor = newTemplateProcessor($filename); // file containing only the text ${test}$html = '<p><span style="background-color: #ff0000;">BugTracker X</span> is ${facing1} an issue.</p>';
$section = newSection(0);
Html::addHtml($section, $html, false, false);
$templateProcessor->setComplexBlock('test', $section);
$facing1 = newTextRun();
$facing1->addText('facing', ['bold' => true]);
$templateProcessor->setComplexValue('facing1', $facing1);
$outputFile = 'anything';
$templateProcessor->saveAs($outputFile);
Expected Behavior
File saved in $outputFile with expected substitutions.
Current Behavior
What is the current behavior?
Fatal error: Uncaught Error: Class "PhpOffice\PhpWord\Writer\Word2007\Element\Section" not found in C:\git\PHPWord\src\PhpWord\TemplateProcessor.php on line 312
A possible solution, if one is warranted, is to use class Container when Section would otherwise be used on the offending lines in setComplexBlock and setComplexValue.
Context
Please fill in your environment information:
PHP Version: 8.1 (but probably any)
PHPWord Version: 1.2 (but probably any)
The text was updated successfully, but these errors were encountered:
Describe the Bug
The TemplateProcessor methods
setComplexBlock
andsetComplexValue
fail when attempting to use them on Sections. It is unclear whether this is by design or just an oversight.Steps to Reproduce
Please provide a code sample that reproduces the issue.
Expected Behavior
File saved in
$outputFile
with expected substitutions.Current Behavior
What is the current behavior?
A possible solution, if one is warranted, is to use class Container when Section would otherwise be used on the offending lines in setComplexBlock and setComplexValue.
Context
Please fill in your environment information:
The text was updated successfully, but these errors were encountered: