Skip to content

Commit

Permalink
Merge pull request #32 from DivanteLtd/extract_dom_parsing
Browse files Browse the repository at this point in the history
Extract DOM parsing to separate service method
  • Loading branch information
wpeisert authored Apr 3, 2020
2 parents af1d081 + 993d7d2 commit f30253b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/PimcoreDevkitBundle/Service/Wysiwyg/WysiwygService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,18 @@ public function addMetaToImages(string $html, string $lang = ''): string
}

$doc = $this->domService->loadHTML($html);
$doc = $this->addMetaToDomImages($doc, $lang);

return $doc->saveHTML();
}

/**
* @param \DOMDocument $doc
* @param string $lang
* @return \DOMDocument
*/
public function addMetaToDomImages(\DOMDocument $doc, string $lang = ''): \DOMDocument
{
/** @var \DOMElement $imgNode */
foreach ($doc->getElementsByTagName('img') as $imgNode) {
$src = $imgNode->getAttribute('src');
Expand All @@ -73,6 +84,6 @@ public function addMetaToImages(string $html, string $lang = ''): string
}
}

return $doc->saveHTML();
return $doc;
}
}

0 comments on commit f30253b

Please sign in to comment.