You are here

protected function DemoImage::createFile in Panopoly 8.2

Creates a new file from the source path.

Parameters

string $source_path: The source path.

string $destination_path: The destination path.

Return value

\Drupal\file\FileInterface The file that was created

Throws

\Drupal\migrate\MigrateException

1 call to DemoImage::createFile()
DemoImage::findOrCreateFile in modules/panopoly/panopoly_core/src/Plugin/migrate/process/DemoImage.php
Finds existing or creates a new file.

File

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

Class

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

Namespace

Drupal\panopoly_core\Plugin\migrate\process

Code

protected function createFile($source_path, $destination_path) {
  if (!$this
    ->copyFile($source_path, $destination_path)) {
    throw new MigrateException("Unable to copy {$source_path} to {$destination_path}");
  }
  $file = $this->fileStorage
    ->create([
    'uri' => $destination_path,
    'status' => TRUE,
  ]);
  $file
    ->save();
  return $file;
}