You are here

protected function DomStrReplace::doReplace in Migrate Plus 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/migrate/process/DomStrReplace.php \Drupal\migrate_plus\Plugin\migrate\process\DomStrReplace::doReplace()

Retrieves the right replace string based on configuration.

Parameters

\DOMElement $html_node: The current element from iteration.

string $search: The search string or pattern.

string $replace: The replacement string.

string $subject: The string on which to perform the substitution.

1 call to DomStrReplace::doReplace()
DomStrReplace::transform in src/Plugin/migrate/process/DomStrReplace.php
Performs the associated process.

File

src/Plugin/migrate/process/DomStrReplace.php, line 178

Class

DomStrReplace
String replacements on a source dom.

Namespace

Drupal\migrate_plus\Plugin\migrate\process

Code

protected function doReplace(\DOMElement $html_node, $search, $replace, $subject) {
  if ($this->configuration['regex']) {
    $function = 'preg_replace';
  }
  elseif ($this->configuration['case_insensitive']) {
    $function = 'str_ireplace';
  }
  else {
    $function = "str_replace";
  }
  $new_subject = $function($search, $replace, $subject);
  $this
    ->postReplace($html_node, $new_subject);
}