protected function FileBlob::putFile in Migrate Plus 8.4
Same name and namespace in other branches
- 8.5 src/Plugin/migrate/process/FileBlob.php \Drupal\migrate_plus\Plugin\migrate\process\FileBlob::putFile()
- 8.2 src/Plugin/migrate/process/FileBlob.php \Drupal\migrate_plus\Plugin\migrate\process\FileBlob::putFile()
- 8.3 src/Plugin/migrate/process/FileBlob.php \Drupal\migrate_plus\Plugin\migrate\process\FileBlob::putFile()
Try to save the file.
Parameters
string $destination: The destination path or URI.
string $blob: The base64 encoded file contents.
int $replace: (optional) either FileSystemInterface::EXISTS_REPLACE; (default) or FileSystemInterface::EXISTS_ERROR, depending on the configuration.
Return value
bool|string File path on success, FALSE on failure.
1 call to FileBlob::putFile()
- FileBlob::transform in src/
Plugin/ migrate/ process/ FileBlob.php - Performs the associated process.
File
- src/
Plugin/ migrate/ process/ FileBlob.php, line 167
Class
- FileBlob
- Copy a file from a blob into a file.
Namespace
Drupal\migrate_plus\Plugin\migrate\processCode
protected function putFile($destination, $blob, $replace = FileSystemInterface::EXISTS_REPLACE) {
// TODO: remove after 8.6 is no longer supported in
// https://www.drupal.org/project/migrate_plus/issues/3035587
if (!isset($replace)) {
$replace = FILE_EXISTS_REPLACE;
}
if (version_compare(\Drupal::VERSION, '8.7', '>=')) {
$path = $this->fileSystem
->getDestinationFilename($destination, $replace);
}
else {
$path = file_destination($destination, $replace);
}
if ($path) {
if (file_put_contents($path, $blob)) {
return $path;
}
else {
return FALSE;
}
}
// File was already copied.
return $destination;
}