You are here

public function ContentExport::download_yml in Content Export YAML 8

download_yml

File

src/ContentExport.php, line 370

Class

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

Namespace

Drupal\content_export_yaml

Code

public function download_yml($yml) {
  $path_file = \Drupal::service('file_system')
    ->realpath("public://temp_yml");
  $file_name = "download";
  $this
    ->delete($path_file . "/" . $file_name . ".yml");
  $status = $this
    ->yml_copy($file_name, $yml, $path_file);
  if ($status) {
    $file_temp = "/sites/default/files/temp_yml/" . $file_name . ".yml";
    @chmod($file_temp, 0777);
    return $file_temp;
  }
  else {
    \Drupal::messenger()
      ->addMessage(t("failed to download"), 'error');
  }
}