function UrlAlias::import
Overrides EntityContentBase::import
File
-
core/
modules/ path/ src/ Plugin/ migrate/ destination/ UrlAlias.php, line 27
Class
- UrlAlias
- Legacy destination class for non-entity path aliases.
Namespace
Drupal\path\Plugin\migrate\destinationCode
public function import(Row $row, array $old_destination_id_values = []) {
if ($row->getDestinationProperty('source')) {
$row->setDestinationProperty('path', $row->getDestinationProperty('source'));
}
$path = $row->getDestinationProperty('path');
// Check if this alias is for a node and if that node is a translation.
if (preg_match('/^\\/node\\/\\d+$/', $path) && $row->hasDestinationProperty('node_translation')) {
// Replace the alias source with the translation source path.
$node_translation = $row->getDestinationProperty('node_translation');
$row->setDestinationProperty('path', '/node/' . $node_translation[0]);
$row->setDestinationProperty('langcode', $node_translation[1]);
}
return parent::import($row, $old_destination_id_values);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.