private function CsvTestBase::recurseCopy in Commerce Migrate 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/CsvTestBase.php \Drupal\Tests\commerce_migrate\Kernel\CsvTestBase::recurseCopy()
- 3.1.x tests/src/Kernel/CsvTestBase.php \Drupal\Tests\commerce_migrate\Kernel\CsvTestBase::recurseCopy()
Helper to copy directory tree.
Parameters
string $src: The source path.
string $dst: The destination path.
Throws
\Drupal\migrate\MigrateException
1 call to CsvTestBase::recurseCopy()
- CsvTestBase::fileMigrationSetup in tests/
src/ Kernel/ CsvTestBase.php - Prepares a public file directory for the migration.
File
- tests/
src/ Kernel/ CsvTestBase.php, line 201
Class
- CsvTestBase
- Test base for migrations tests with CSV source file.
Namespace
Drupal\Tests\commerce_migrate\KernelCode
private function recurseCopy($src, $dst) {
$dir = opendir($src);
if (!file_exists($dst)) {
$this->fs
->mkdir($dst, NULL, TRUE);
}
$file_system = \Drupal::service('file_system');
while (FALSE !== ($file = readdir($dir))) {
if ($file != '.' && $file != '..') {
if (is_dir($src . '/' . $file)) {
$this
->recurseCopy($src . '/' . $file, $dst . '/' . $file);
}
else {
if (!$file_system
->copy($src . '/' . $file, $dst . '/' . $file)) {
$fixture = $src . '/' . $file;
$destination_uri = $dst . '/' . $file;
throw new MigrateException("Migration setup failed to copy source CSV file '{$fixture}' to '{$destination_uri}'.");
}
}
}
}
closedir($dir);
}