src/Composer/ComposerHydrationHandler.php
public function hydrateRenameFilesAndFolders($replaceMap)
    {
        $io = $this->event->getIO();

        $finder = new Finder();
        $finder->in($this->basePath);
        $finder->ignoreDotFiles(false);
        $finder->exclude('vendor');

        foreach ($replaceMap as $search => $replace) {
            // Restrict files by search.
            $finder->name(".*$search*");
            $finder->name("*$search*");
        }

        $count = iterator_count($finder);
        if (!$count) {
            $io->write("[Hydration][OK] Skipping, no folders and files to be renamed.");

            return;
        }

        $io->write("[Hydration][INFO] Renaming $count file(s)/folder(s).");

        $finder = array_keys(iterator_to_array($finder, true));
        foreach ($finder as $currentName) {
            $newName = str_replace(array_keys($replaceMap), array_values($replaceMap), $currentName);

            // Replace values.
            $renamed = rename($currentName, $newName);
            if (!$renamed) {
                // Failed.
                throw new \ErrorException("Unable to rename file/folder: $currentName");
            }

            // Success.
            $io->write("[Hydration][OK] Renamed $currentName ---> $newName");
        }
    }
public function hydrateRenameFilesAndFolders($replaceMap)
    {
        $io = $this->event->getIO();

        $finder = new Finder();
        $finder->in($this->basePath);
        $finder->ignoreDotFiles(false);
        $finder->exclude('vendor');

        foreach ($replaceMap as $search => $replace) {
            // Restrict files by search.
            $finder->name(".*$search*");
            $finder->name("*$search*");
        }

        $count = iterator_count($finder);
        if (!$count) {
            $io->write("[Hydration][OK] Skipping, no folders and files to be renamed.");

            return;
        }

        $io->write("[Hydration][INFO] Renaming $count file(s)/folder(s).");

        $finder = array_keys(iterator_to_array($finder, true));
        foreach ($finder as $currentName) {
            $newName = str_replace(array_keys($replaceMap), array_values($replaceMap), $currentName);

            // Replace values.
            $renamed = rename($currentName, $newName);
            if (!$renamed) {
                // Failed.
                throw new \ErrorException("Unable to rename file/folder: $currentName");
            }

            // Success.
            $io->write("[Hydration][OK] Renamed $currentName ---> $newName");
        }
    }
public function hydrateRenameFilesAndFolders ( $ replaceMap ) { $ io = $ this -> event -> getIO ( ) ; $ finder = new Finder ( ) ; $ finder -> in ( $ this -> basePath ) ; $ finder -> ignoreDotFiles ( false ) ; $ finder -> exclude ( 'vendor' ) ; foreach ( $ replaceMap as $ search => $ replace ) { // Restrict files by search. $ finder -> name ( ".*$search*" ) ; $ finder -> name ( "*$search*" ) ; } $ count = iterator_count ( $ finder ) ; if ( ! $ count ) { $ io -> write ( "[Hydration][OK] Skipping, no folders and files to be renamed." ) ; return ; } $ io -> write ( "[Hydration][INFO] Renaming $count file(s)/folder(s)." ) ; $ finder = array_keys ( iterator_to_array ( $ finder , true ) ) ; foreach ( $ finder as $ currentName ) { $ newName = str_replace ( array_keys ( $ replaceMap ) , array_values ( $ replaceMap ) , $ currentName ) ; // Replace values. $ renamed = rename ( $ currentName , $ newName ) ; if ( ! $ renamed ) { // Failed. throw new \ ErrorException ( "Unable to rename file/folder: $currentName" ) ; } // Success. $ io -> write ( "[Hydration][OK] Renamed $currentName ---> $newName" ) ; } }
Process hydration renaming files and folders.

@param string $replaceMap
An array containing the replacement map following the format:
[{SEARCH} => {REPLACE},
{SEARCH} => {REPLACE},
...]
Process hydration renaming files and folders .