You are here

protected function DemoImage::copyFile in Panopoly 8.2

Copy the file.

Parameters

string $source_path: The source path.

string $destination_path: The destination path.

Return value

bool TRUE if successful; otherwise FALSE.

1 call to DemoImage::copyFile()
DemoImage::createFile in modules/panopoly/panopoly_core/src/Plugin/migrate/process/DemoImage.php
Creates a new file from the source path.

File

modules/panopoly/panopoly_core/src/Plugin/migrate/process/DemoImage.php, line 158

Class

DemoImage
Process plugin for creating demo images from files in the module.

Namespace

Drupal\panopoly_core\Plugin\migrate\process

Code

protected function copyFile($source_path, $destination_path) {
  $dir = $this->filesystem
    ->dirname($destination_path);

  // Apparently, file_prepare_directory() can't deal with a protocol but no
  // path, so we convert it to the real path.
  if (substr($dir, -3) == '://') {
    $dir = $this->filesystem
      ->realpath($dir);
  }
  if ($this->filesystem
    ->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
    return @copy($source_path, $destination_path);
  }
  return FALSE;
}