src/RecipeInstaller.php
protected function installProjectFiles(
        $recipe,
        $sourceRoot,
        $destinationRoot,
        $filePatterns,
        $registrationKey,
        $name = 'project'
    ) {
        // load composer json data
        $composerFile = new JsonFile(Factory::getComposerFile(), null, $this->io);
        $composerData = $composerFile->read();
        $installedFiles = isset($composerData['extra'][$registrationKey])
            ? $composerData['extra'][$registrationKey]
            : [];

        // Load all project files
        $fileIterator = $this->getFileIterator($sourceRoot, $filePatterns);
        $any = false;
        foreach ($fileIterator as $path => $info) {
            // Write header on first file
            if (!$any) {
                $this->io->write("Installing {$name} files for recipe <info>{$recipe}</info>:");
                $any = true;
            }

            // Install this file
            $relativePath = $this->installProjectFile($sourceRoot, $destinationRoot, $path, $installedFiles);

            // Add file to installed (even if already exists)
            if (!in_array($relativePath, $installedFiles)) {
                $installedFiles[] = $relativePath;
            }
        }

        // If any files are written, modify composer.json with newly installed files
        if ($installedFiles) {
            sort($installedFiles);
            if (!isset($composerData['extra'])) {
                $composerData['extra'] = [];
            }
            $composerData['extra'][$registrationKey] = $installedFiles;
            $composerFile->write($composerData);
        }
    }
protected function installProjectFiles(
        $recipe,
        $sourceRoot,
        $destinationRoot,
        $filePatterns,
        $registrationKey,
        $name = 'project'
    ) {
        // load composer json data
        $composerFile = new JsonFile(Factory::getComposerFile(), null, $this->io);
        $composerData = $composerFile->read();
        $installedFiles = isset($composerData['extra'][$registrationKey])
            ? $composerData['extra'][$registrationKey]
            : [];

        // Load all project files
        $fileIterator = $this->getFileIterator($sourceRoot, $filePatterns);
        $any = false;
        foreach ($fileIterator as $path => $info) {
            // Write header on first file
            if (!$any) {
                $this->io->write("Installing {$name} files for recipe <info>{$recipe}</info>:");
                $any = true;
            }

            // Install this file
            $relativePath = $this->installProjectFile($sourceRoot, $destinationRoot, $path, $installedFiles);

            // Add file to installed (even if already exists)
            if (!in_array($relativePath, $installedFiles)) {
                $installedFiles[] = $relativePath;
            }
        }

        // If any files are written, modify composer.json with newly installed files
        if ($installedFiles) {
            sort($installedFiles);
            if (!isset($composerData['extra'])) {
                $composerData['extra'] = [];
            }
            $composerData['extra'][$registrationKey] = $installedFiles;
            $composerFile->write($composerData);
        }
    }
protected function installProjectFiles ( $ recipe , $ sourceRoot , $ destinationRoot , $ filePatterns , $ registrationKey , $ name = 'project' ) { // load composer json data $ composerFile = new JsonFile ( Factory :: getComposerFile ( ) , null , $ this -> io ) ; $ composerData = $ composerFile -> read ( ) ; $ installedFiles = isset ( $ composerData [ 'extra' ] [ $ registrationKey ] ) ? $ composerData [ 'extra' ] [ $ registrationKey ] : [ ] ; // Load all project files $ fileIterator = $ this -> getFileIterator ( $ sourceRoot , $ filePatterns ) ; $ any = false ; foreach ( $ fileIterator as $ path => $ info ) { // Write header on first file if ( ! $ any ) { $ this -> io -> write ( "Installing {$name} files for recipe <info>{$recipe}</info>:" ) ; $ any = true ; } // Install this file $ relativePath = $ this -> installProjectFile ( $ sourceRoot , $ destinationRoot , $ path , $ installedFiles ) ; // Add file to installed (even if already exists) if ( ! in_array ( $ relativePath , $ installedFiles ) ) { $ installedFiles [ ] = $ relativePath ; } } // If any files are written, modify composer.json with newly installed files if ( $ installedFiles ) { sort ( $ installedFiles ) ; if ( ! isset ( $ composerData [ 'extra' ] ) ) { $ composerData [ 'extra' ] = [ ] ; } $ composerData [ 'extra' ] [ $ registrationKey ] = $ installedFiles ; $ composerFile -> write ( $ composerData ) ; } }
Install project files in the specified directory

@param string $recipe Recipe name
@param string $sourceRoot Base of source files (no trailing slash)
@param string $destinationRoot Base of destination directory (no trailing slash)
@param array $filePatterns List of file patterns in wildcard format (e.g. `code/My*.php`)
@param string $registrationKey Registration key for installed files
@param string $name Name of project file type being installed
Install project files in the specified directory