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

        $finder = new Finder();
        $finder->in($this->basePath);
        $finder->ignoreDotFiles(false);
        $finder->notPath('vendor');
        $finder->notName('composer.json');

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

        $count = iterator_count($finder);
        if (!$count) {
            $io->write("[Hydration][OK] Skipping, no file contents to be replaced.");

            return;
        }

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

        foreach ($finder as $file) {
            $filePath = $file->getRelativePathname();

            // Replace values.
            $fileContent = str_replace(array_keys($replaceMap), array_values($replaceMap), $file->getContents());

            // Save file with new replaced content.
            if (!file_put_contents($filePath, $fileContent)) {
                // Failed.
                $msg = "Unable to Hydrate the file, check the file permissions and try again: $filePath";
                throw new \ErrorException($msg);
            }

            // Success.
            $io->write("[Hydration][OK] File Hydrated: $filePath");
        }
    }
public function hydrateFileContents($replaceMap)
    {
        $io = $this->event->getIO();

        $finder = new Finder();
        $finder->in($this->basePath);
        $finder->ignoreDotFiles(false);
        $finder->notPath('vendor');
        $finder->notName('composer.json');

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

        $count = iterator_count($finder);
        if (!$count) {
            $io->write("[Hydration][OK] Skipping, no file contents to be replaced.");

            return;
        }

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

        foreach ($finder as $file) {
            $filePath = $file->getRelativePathname();

            // Replace values.
            $fileContent = str_replace(array_keys($replaceMap), array_values($replaceMap), $file->getContents());

            // Save file with new replaced content.
            if (!file_put_contents($filePath, $fileContent)) {
                // Failed.
                $msg = "Unable to Hydrate the file, check the file permissions and try again: $filePath";
                throw new \ErrorException($msg);
            }

            // Success.
            $io->write("[Hydration][OK] File Hydrated: $filePath");
        }
    }
public function hydrateFileContents ( $ replaceMap ) { $ io = $ this -> event -> getIO ( ) ; $ finder = new Finder ( ) ; $ finder -> in ( $ this -> basePath ) ; $ finder -> ignoreDotFiles ( false ) ; $ finder -> notPath ( 'vendor' ) ; $ finder -> notName ( 'composer.json' ) ; // Find files. foreach ( $ replaceMap as $ search => $ replace ) { // Restrict files by search. $ finder -> contains ( $ search ) ; } $ count = iterator_count ( $ finder ) ; if ( ! $ count ) { $ io -> write ( "[Hydration][OK] Skipping, no file contents to be replaced." ) ; return ; } $ io -> write ( "[Hydration][INFO] Hydrating $count file(s)." ) ; foreach ( $ finder as $ file ) { $ filePath = $ file -> getRelativePathname ( ) ; // Replace values. $ fileContent = str_replace ( array_keys ( $ replaceMap ) , array_values ( $ replaceMap ) , $ file -> getContents ( ) ) ; // Save file with new replaced content. if ( ! file_put_contents ( $ filePath , $ fileContent ) ) { // Failed. $ msg = "Unable to Hydrate the file, check the file permissions and try again: $filePath" ; throw new \ ErrorException ( $ msg ) ; } // Success. $ io -> write ( "[Hydration][OK] File Hydrated: $filePath" ) ; } }
Process hydration to File contents.

@param string $replaceMap
An array containing the replacement map following the format:
[{SEARCH} => {REPLACE},
{SEARCH} => {REPLACE},
...]
Process hydration to File contents .