| 1 |
<?php |
| 2 |
|
| 3 |
namespace AcyMailing\Helpers; |
| 4 |
|
| 5 |
use Pelago\Emogrifier\CssInliner; |
| 6 |
|
| 7 |
class CssInlinerHelper extends CssInliner |
| 8 |
{ |
| 9 |
public function renderBodyContent(): string |
| 10 |
{ |
| 11 |
$htmlWithPossibleErroneousClosingTags = $this->getDomDocument()->saveHTML($this->getBodyElement()); |
| 12 |
|
| 13 |
return $this->removeSelfClosingTagsClosingTags($htmlWithPossibleErroneousClosingTags); |
| 14 |
} |
| 15 |
|
| 16 |
protected function addStyleElementToDocument(string $css): void |
| 17 |
{ |
| 18 |
global $emogrifiedMediaCSS; |
| 19 |
$emogrifiedMediaCSS = $css; |
| 20 |
} |
| 21 |
|
| 22 |
private function getBodyElement(): \DOMElement |
| 23 |
{ |
| 24 |
$node = $this->getDomDocument()->getElementsByTagName('body')->item(0); |
| 25 |
if (!$node instanceof \DOMElement) { |
| 26 |
throw new \RuntimeException('There is no body element.', 1617922607); |
| 27 |
} |
| 28 |
|
| 29 |
return $node; |
| 30 |
} |
| 31 |
|
| 32 |
private function removeSelfClosingTagsClosingTags(string $html): string |
| 33 |
{ |
| 34 |
return \preg_replace('%</'.self::PHP_UNRECOGNIZED_VOID_TAGNAME_MATCHER.'>%', '', $html); |
| 35 |
} |
| 36 |
|
| 37 |
public function getMatchingUninlinableSelectors(): array |
| 38 |
{ |
| 39 |
$selectors = parent::getMatchingUninlinableSelectors(); |
| 40 |
$selectors[] = '.hideonline'; |
| 41 |
$selectors[] = '#acym__wysid__template center > table'; |
| 42 |
|
| 43 |
return $selectors; |
| 44 |
} |
| 45 |
} |
| 46 |
|