" . PHP_EOL;
} else {
$content .= "
" . PHP_EOL;
}
$writer = new Container($this->getParentWriter(), $section);
$content .= $writer->write();
$content .= '
' . PHP_EOL;
}
$content .= $this->writeNotes();
$content .= '' . PHP_EOL;
return $content;
}
/**
* Write footnote/endnote contents as textruns.
*
* @return string
*/
private function writeNotes()
{
/** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */
$parentWriter = $this->getParentWriter();
$phpWord = $parentWriter->getPhpWord();
$notes = $parentWriter->getNotes();
$content = '';
if (!empty($notes)) {
$content .= '
' . PHP_EOL;
foreach ($notes as $noteId => $noteMark) {
[$noteType, $noteTypeId] = explode('-', $noteMark);
$method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes');
$collection = $phpWord->$method()->getItems();
if (isset($collection[$noteTypeId])) {
$element = $collection[$noteTypeId];
$noteAnchor = "
";
$noteAnchor .= "
{$noteId}";
$writer = new TextRunWriter($this->getParentWriter(), $element);
$writer->setOpeningText($noteAnchor);
$content .= $writer->write();
}
}
}
return $content;
}
}