You are here

protected function ImportTrainingForm::copyFile in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Form/ImportTrainingForm.php \Drupal\opigno_module\Form\ImportTrainingForm::copyFile()

Prepare Directories and copy needed files.

Parameters

string $file_source: Source file.

string $destination: Destination file.

string $dest_folder: Destination folder.

Return value

string

3 calls to ImportTrainingForm::copyFile()
ImportTrainingForm::importActivity in src/Form/ImportTrainingForm.php
Create Opigno Activity entity.
ImportTrainingForm::importTrainingImage in src/Form/ImportTrainingForm.php
Create Media Image for training entity.
ImportTrainingForm::submitForm in src/Form/ImportTrainingForm.php
Form submission handler.

File

src/Form/ImportTrainingForm.php, line 984

Class

ImportTrainingForm
Import Course form.

Namespace

Drupal\opigno_module\Form

Code

protected function copyFile($file_source, $destination, $dest_folder) {
  $this->fileSystem
    ->prepareDirectory($dest_folder, FileSystemInterface::MODIFY_PERMISSIONS | FileSystemInterface::CREATE_DIRECTORY);
  $uri = '';
  try {
    $uri = $this->fileSystem
      ->copy($file_source, $destination, FileSystemInterface::EXISTS_RENAME);
  } catch (\Exception $e) {
    \Drupal::logger('opigno_groups_migration')
      ->error($e
      ->getMessage());
  }
  return $uri;
}