PathRedirect.php in Redirect 8
File
src/Plugin/migrate/process/d7/PathRedirect.php
View source
<?php
namespace Drupal\redirect\Plugin\migrate\process\d7;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
class PathRedirect extends ProcessPluginBase {
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (preg_match('#^http#', $value[0])) {
$uri = $value[0];
}
else {
$uri = 'internal:/' . $value[0];
}
if (!empty($value[1])) {
$options = unserialize($value[1]);
if (!empty($options['query'])) {
$uri .= '?' . http_build_query($options['query']);
}
if (!empty($options['fragment'])) {
$uri .= '#' . $options['fragment'];
}
}
return $uri;
}
}
Classes
Name |
Description |
PathRedirect |
Plugin annotation
@MigrateProcessPlugin(
id = "d7_path_redirect"
) |