function FixtureUtilityTrait::renameGitDirectories

Renames _git directories to .git.

Parameters

string $dir: The directory to be iterated through.

1 call to FixtureUtilityTrait::renameGitDirectories()
FixtureUtilityTrait::copyFixtureFilesTo in core/modules/package_manager/tests/src/Traits/FixtureUtilityTrait.php
Mirrors a fixture directory to the given path.

File

core/modules/package_manager/tests/src/Traits/FixtureUtilityTrait.php, line 66

Class

FixtureUtilityTrait
A utility for all things fixtures.

Namespace

Drupal\Tests\package_manager\Traits

Code

private static function renameGitDirectories(string $dir) : void {
    $iter = new \RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST, \RecursiveIteratorIterator::CATCH_GET_CHILD);
    
    /** @var \Symfony\Component\Finder\SplFileInfo $file */
    foreach ($iter as $file) {
        if ($file->isDir() && $file->getFilename() === '_git' && $file->getRelativePathname()) {
            rename($file->getPathname(), $file->getPath() . DIRECTORY_SEPARATOR . '.git');
        }
    }
}

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