Same filename and directory in other branches
- 8.9.x core/modules/file/src/Plugin/migrate/process/d6/FileUri.php
- 9 core/modules/file/src/Plugin/migrate/process/d6/FileUri.php
Namespace
Drupal\file\Plugin\migrate\process\d6
File
core/modules/file/src/Plugin/migrate/process/d6/FileUri.php
View source
<?php
namespace Drupal\file\Plugin\migrate\process\d6;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
class FileUri extends ProcessPluginBase {
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if ($row
->isStub()) {
return NULL;
}
[
$filepath,
$file_directory_path,
$temp_directory_path,
$is_public,
] = $value;
if (str_starts_with($filepath, $temp_directory_path)) {
$uri = preg_replace('/^' . preg_quote($temp_directory_path, '/') . '/', '', $filepath);
return 'temporary://' . ltrim($uri, '/');
}
$uri = preg_replace('/^' . preg_quote($file_directory_path, '/') . '/', '', $filepath);
return ($is_public ? 'public' : 'private') . '://' . ltrim($uri, '/');
}
}
Classes
Name |
Description |
FileUri |
Process the file URL into a D8 compatible URL. |