MediaInternetFieldValue.php in Media Migration 8
File
src/Plugin/migrate/process/MediaInternetFieldValue.php
View source
<?php
namespace Drupal\media_migration\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
class MediaInternetFieldValue extends ProcessPluginBase {
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$source_values = $row
->getSource();
$replaced = preg_replace([
'/^youtube:\\/\\/v\\//i',
'/^vimeo:\\/\\/v\\//i',
], [
'https://www.youtube.com/watch?v=',
'https://vimeo.com/',
], $source_values['uri']);
if ($replaced !== $source_values['uri']) {
return $replaced;
}
return $value;
}
}