protected function AlinkPostRenderer::processDomNodeList in Alinks 8
Process the node list to replace links.
File
- src/
AlinkPostRenderer.php, line 152
Class
- AlinkPostRenderer
- Class AlinkPostRenderer.
Namespace
Drupal\alinksCode
protected function processDomNodeList($element) {
foreach ($element as $item) {
if ($item instanceof \DOMElement) {
if ($item
->hasChildNodes()) {
foreach ($item->childNodes as $childNode) {
if ($childNode instanceof \DOMText) {
foreach ($this
->getKeywords() as $word) {
// @TODO: Make it configurable replaceAll vs. replaceFirst
$childNode->nodeValue = $this
->replaceFirst($word, '<a href="' . $word
->getUrl() . '">' . $word
->getText() . '</a>', $childNode->nodeValue);
}
}
}
}
}
}
return $element;
}