function FixtureUtilityTrait::renameInfoYmlFiles

Renames all files that end with .info.yml.hide.

Parameters

string $dir: The directory to be iterated through.

1 call to FixtureUtilityTrait::renameInfoYmlFiles()
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 47

Class

FixtureUtilityTrait
A utility for all things fixtures.

Namespace

Drupal\Tests\package_manager\Traits

Code

protected static function renameInfoYmlFiles(string $dir) : void {
    // Construct the iterator.
    $it = new RecursiveDirectoryIterator($dir, \RecursiveIteratorIterator::SELF_FIRST);
    // Loop through files and rename them.
    foreach (new \RecursiveIteratorIterator($it) as $file) {
        if ($file->getExtension() == 'hide') {
            rename($file->getPathname(), $dir . DIRECTORY_SEPARATOR . $file->getRelativePath() . DIRECTORY_SEPARATOR . str_replace(".hide", "", $file->getFilename()));
        }
    }
}

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