You are here

protected function FileCopy::writeFile in Migrate Plus 8.2

Tries to move or copy a file.

Parameters

string $source: The source path or URI.

string $destination: The destination path or URI.

int $replace: (optional) FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME.

Return value

string|bool File destination on success, FALSE on failure.

1 call to FileCopy::writeFile()
FileCopy::transform in src/Plugin/migrate/process/FileCopy.php
Performs the associated process.

File

src/Plugin/migrate/process/FileCopy.php, line 129

Class

FileCopy
Copy a file from one place into another.

Namespace

Drupal\migrate_plus\Plugin\migrate\process

Code

protected function writeFile($source, $destination, $replace = FILE_EXISTS_REPLACE) {
  if ($this->configuration['move']) {
    return file_unmanaged_move($source, $destination, $replace);
  }

  // We can't use file_unmanaged_copy because it will break with remote Urls.
  $final_destination = file_destination($destination, $replace);
  if (@copy($source, $final_destination)) {
    return $final_destination;
  }
  return FALSE;
}