function PathSetTranslated::transform

Same name and namespace in other branches
  1. 9 core/modules/path/src/Plugin/migrate/process/PathSetTranslated.php \Drupal\path\Plugin\migrate\process\PathSetTranslated::transform()
  2. 8.9.x core/modules/path/src/Plugin/migrate/process/PathSetTranslated.php \Drupal\path\Plugin\migrate\process\PathSetTranslated::transform()
  3. 10 core/modules/path/src/Plugin/migrate/process/PathSetTranslated.php \Drupal\path\Plugin\migrate\process\PathSetTranslated::transform()

Overrides ProcessPluginBase::transform

File

core/modules/path/src/Plugin/migrate/process/PathSetTranslated.php, line 60

Class

PathSetTranslated
A process plugin to update the path of a translated node.

Namespace

Drupal\path\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    if (!is_array($value)) {
        throw new MigrateException("The input value should be an array.");
    }
    $path = $value[0] ?? '';
    $nid = is_array($value[1]) && isset($value[1][0]) ? $value[1][0] : FALSE;
    if (preg_match('/^\\/node\\/\\d+$/', $path) && $nid) {
        return '/node/' . $nid;
    }
    return $path;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.