You are here

public function MockDrupalGatherContentClient::downloadFiles in GatherContent 8.5

Same name and namespace in other branches
  1. 8.4 tests/modules/gathercontent_test/src/MockDrupalGatherContentClient.php \Drupal\gathercontent_test\MockDrupalGatherContentClient::downloadFiles()

Mock download.

Overrides DrupalGatherContentClient::downloadFiles

File

tests/modules/gathercontent_test/src/MockDrupalGatherContentClient.php, line 23

Class

MockDrupalGatherContentClient
Class to mock GC client.

Namespace

Drupal\gathercontent_test

Code

public function downloadFiles(array $files, $directory, $language) {
  $importedFiles = [];
  foreach ($files as $file) {
    $importedFile = File::create([
      'filename' => $file->fileName,
      'uri' => $file->url,
      'status' => 1,
      'gc_id' => $file->id,
      'langcode' => $language,
      'filesize' => $file->size,
    ]);
    $importedFile
      ->save();
    $importedFiles[] = $importedFile
      ->id();
  }
  return $importedFiles;
}