function InstallerConfigDirectoryTestBase::copyDirectory

This copies a source directory to a destination directory recursively.

Parameters

string $source: Source directory.

string $destination: Destination directory.

1 call to InstallerConfigDirectoryTestBase::copyDirectory()
InstallerConfigDirectoryTestBase::prepareEnvironment in core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectoryTestBase.php
Prepares the current environment for running the test.

File

core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectoryTestBase.php, line 38

Class

InstallerConfigDirectoryTestBase
Provides a base class for testing installing from existing configuration.

Namespace

Drupal\FunctionalTests\Installer

Code

protected function copyDirectory(string $source, string $destination) : void {
    if (!is_dir($destination)) {
        mkdir($destination, 0755, TRUE);
    }
    $files = scandir($source);
    foreach ($files as $file) {
        if ($file !== '.' && $file !== '..') {
            $sourceFile = $source . '/' . $file;
            $destinationFile = $destination . '/' . $file;
            if (is_dir($sourceFile)) {
                $this->copyDirectory($sourceFile, $destinationFile);
            }
            else {
                copy($sourceFile, $destinationFile);
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.