You are here

function ContentExport::yml_copy in Content Export YAML 8

Copy yaml to another folder

1 call to ContentExport::yml_copy()
ContentExport::download_yml in src/ContentExport.php
download_yml

File

src/ContentExport.php, line 388

Class

ContentExport
Created by PhpStorm. User: USER Date: 11/13/18 Time: 2:04 PM

Namespace

Drupal\content_export_yaml

Code

function yml_copy($file_name, $file_with_path, $path_export) {
  $file_full_path = DRUPAL_ROOT . $file_with_path;
  $fileSystem = \Drupal::service('file_system');
  if (!is_dir($path_export)) {
    if ($fileSystem
      ->mkdir($path_export, 0777, TRUE) === FALSE) {
      $this->logger
        ->error('Failed to create directory ' . $path_export);
      return FALSE;
    }
  }
  if (!copy($file_full_path, $path_export . "/" . $file_name . ".yml")) {
    \Drupal::messenger()
      ->addMessage(t("failed to copy {$file_with_path}"), 'error');
    return FALSE;
  }
  else {
    \Drupal::messenger()
      ->addMessage(t("Upload Success"), 'error');
    @chmod($path_export . "/" . $file_name . ".yml", 0777);
    return TRUE;
  }
}