You are here

public function DomStrReplace::transform in Migrate Plus 8.5

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

Performs the associated process.

Parameters

mixed $value: The value to be transformed.

\Drupal\migrate\MigrateExecutableInterface $migrate_executable: The migration in which this process is being executed.

\Drupal\migrate\Row $row: The row from the source to process. Normally, just transforming the value is adequate but very rarely you might need to change two columns at the same time or something like that.

string $destination_property: The destination property currently worked on. This is only used together with the $row above.

Return value

string|array The newly transformed value.

Overrides ProcessPluginBase::transform

1 method overrides DomStrReplace::transform()
DomMigrationLookup::transform in src/Plugin/migrate/process/DomMigrationLookup.php
Performs the associated process.

File

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

Class

DomStrReplace
String replacements on a source dom.

Namespace

Drupal\migrate_plus\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  $this
    ->init($value, $destination_property);
  foreach ($this->xpath
    ->query($this->configuration['xpath']) as $html_node) {
    $subject = $this
      ->getSubject($html_node);
    if (empty($subject)) {

      // Could not find subject, skip processing.
      continue;
    }
    $search = $this
      ->getSearch();
    $replace = $this
      ->getReplace();
    $this
      ->doReplace($html_node, $search, $replace, $subject);
  }
  return $this->document;
}