protected function DomStrReplace::postReplace in Migrate Plus 8.5
Same name and namespace in other branches
- 8.4 src/Plugin/migrate/process/DomStrReplace.php \Drupal\migrate_plus\Plugin\migrate\process\DomStrReplace::postReplace()
Performs post-replace actions.
Parameters
\DOMElement $html_node: The current element from iteration.
string $new_subject: The new value to use.
2 calls to DomStrReplace::postReplace()
- DomMigrationLookup::doReplace in src/
Plugin/ migrate/ process/ DomMigrationLookup.php - Retrieves the right replace string based on configuration.
- DomStrReplace::doReplace in src/
Plugin/ migrate/ process/ DomStrReplace.php - Retrieves the right replace string based on configuration.
File
- src/
Plugin/ migrate/ process/ DomStrReplace.php, line 270
Class
- DomStrReplace
- String replacements on a source dom.
Namespace
Drupal\migrate_plus\Plugin\migrate\processCode
protected function postReplace(\DOMElement $html_node, $new_subject) {
switch ($this->configuration['mode']) {
case 'attribute':
$html_node
->setAttribute($this->configuration['attribute_options']['name'], $new_subject);
break;
case 'element':
$new_node = $this->document
->createElement($new_subject);
foreach ($html_node->childNodes as $child) {
$new_node
->appendChild($child
->cloneNode(TRUE));
}
foreach ($html_node->attributes as $attribute) {
$new_node
->setAttribute($attribute->name, $attribute->value);
}
$html_node->parentNode
->replaceChild($new_node, $html_node);
break;
}
}