Skip to content

Commit 9a17db4

Browse files
Fix incorrect key while injecting new contents
1 parent 0e0cbfc commit 9a17db4

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/Label305/DocxExtractor/Decorated/DecoratedTextInjector.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,20 @@ protected function assignMappedValues(DOMNode $node, $mapping)
5757
if (count($results) > 0) {
5858
$key = trim($results[0], '%');
5959

60-
$parent = $node->parentNode;
61-
62-
if ($this->direction !== null) {
63-
$styleNode = $this->addOrFindParagraphStyleNode($parent);
64-
$this->addParagraphDirection($styleNode);
65-
}
66-
67-
foreach ($mapping[$key] as $sentence) {
68-
$fragment = $parent->ownerDocument->createDocumentFragment();
69-
$fragment->appendXML($sentence->toDocxXML());
70-
$parent->insertBefore($fragment, $node);
60+
if (isset($mapping[$key])) {
61+
$parent = $node->parentNode;
62+
63+
if ($this->direction !== null) {
64+
$styleNode = $this->addOrFindParagraphStyleNode($parent);
65+
$this->addParagraphDirection($styleNode);
66+
}
67+
foreach ($mapping[$key] as $sentence) {
68+
$fragment = $parent->ownerDocument->createDocumentFragment();
69+
$fragment->appendXML($sentence->toDocxXML());
70+
$parent->insertBefore($fragment, $node);
71+
}
72+
$parent->removeChild($node);
7173
}
72-
$parent->removeChild($node);
7374
}
7475
}
7576

0 commit comments

Comments
 (0)