public function FileRemoteUrl::transform in Migrate Files (extended) 8
Same name and namespace in other branches
- 2.0.x src/Plugin/migrate/process/FileRemoteUrl.php \Drupal\migrate_file\Plugin\migrate\process\FileRemoteUrl::transform()
Performs the associated process.
Parameters
mixed $value: The value to be transformed.
\Drupal\migrate\MigrateExecutableInterface $migrate_executable: The migration in which this process is being executed.
\Drupal\migrate\Row $row: The row from the source to process. Normally, just transforming the value is adequate but very rarely you might need to change two columns at the same time or something like that.
string $destination_property: The destination property currently worked on. This is only used together with the $row above.
Return value
string|array The newly transformed value.
Overrides ProcessPluginBase::transform
1 call to FileRemoteUrl::transform()
- FileRemoteImage::transform in src/
Plugin/ migrate/ process/ FileRemoteImage.php - Performs the associated process.
1 method overrides FileRemoteUrl::transform()
- FileRemoteImage::transform in src/
Plugin/ migrate/ process/ FileRemoteImage.php - Performs the associated process.
File
- src/
Plugin/ migrate/ process/ FileRemoteUrl.php, line 60
Class
- FileRemoteUrl
- Create a file entity with a remote url without downloading the file.
Namespace
Drupal\migrate_file\Plugin\migrate\processCode
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
// If we're stubbing a file entity, return a URI of NULL so it will get
// stubbed by the general process.
if (!$value) {
return NULL;
}
// Create a file entity.
$file = File::create([
'uri' => $value,
'uid' => $this->configuration['uid'],
'status' => FILE_STATUS_PERMANENT,
]);
$file
->save();
return $file;
}