Move getElementInnerHTML from button to DomDocumentHelper
[MAILPOET-5741]
This commit is contained in:
committed by
Rostislav Wolný
parent
febc070c0f
commit
aa658782fb
@@ -27,7 +27,8 @@ class Button implements BlockRenderer {
|
||||
$markup = str_replace('{classes}', $buttonClasses, $markup);
|
||||
|
||||
// Add Link Text
|
||||
$markup = str_replace('{linkText}', $this->getElementInnerHTML($buttonLink) ?: '', $markup);
|
||||
// Because the button text can contain highlighted text, we need to get the inner HTML of the button
|
||||
$markup = str_replace('{linkText}', $domHelper->getElementInnerHTML($buttonLink) ?: '', $markup);
|
||||
$markup = str_replace('{linkUrl}', $buttonLink->getAttribute('href') ?: '#', $markup);
|
||||
|
||||
// Width
|
||||
@@ -115,19 +116,4 @@ class Button implements BlockRenderer {
|
||||
</tr>
|
||||
</table>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Because the button text can contain highlighted text, we need to get the inner HTML of the button
|
||||
*/
|
||||
private function getElementInnerHTML(\DOMElement $element): string {
|
||||
$innerHTML = '';
|
||||
$children = $element->childNodes;
|
||||
foreach ($children as $child) {
|
||||
if (!$child instanceof \DOMNode) continue;
|
||||
$ownerDocument = $child->ownerDocument;
|
||||
if (!$ownerDocument instanceof \DOMDocument) continue;
|
||||
$innerHTML .= $ownerDocument->saveXML($child);
|
||||
}
|
||||
return $innerHTML;
|
||||
}
|
||||
}
|
||||
|
@@ -47,4 +47,14 @@ class DomDocumentHelper {
|
||||
public function getOuterHtml(\DOMElement $element): string {
|
||||
return (string)$this->dom->saveHTML($element);
|
||||
}
|
||||
|
||||
public function getElementInnerHTML(\DOMElement $element): string {
|
||||
$innerHTML = '';
|
||||
$children = $element->childNodes;
|
||||
foreach ($children as $child) {
|
||||
if (!$child instanceof \DOMNode) continue;
|
||||
$innerHTML .= $this->dom->saveHTML($child);
|
||||
}
|
||||
return $innerHTML;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user