src/RecipeInstaller.php
protected function getFileIterator($sourceRoot, $patterns)
    {
        // Build regexp pattern
        $expressions = [];
        foreach ($patterns as $pattern) {
            $expressions[] = $this->globToRegexp($pattern);
        }
        $regExp = '#^' . $this->globToRegexp($sourceRoot . '/').'(('.implode(')|(', $expressions).'))$#';

        // Build directory iterator
        $directoryIterator = new RecursiveDirectoryIterator(
            $sourceRoot,
            FilesystemIterator::SKIP_DOTS
                | FilesystemIterator::UNIX_PATHS
                | FilesystemIterator::KEY_AS_PATHNAME
                | FilesystemIterator::CURRENT_AS_FILEINFO
        );

        // Return filtered iterator
        $iterator = new RecursiveIteratorIterator($directoryIterator);
        return new RegexIterator($iterator, $regExp);
    }
protected function getFileIterator($sourceRoot, $patterns)
    {
        // Build regexp pattern
        $expressions = [];
        foreach ($patterns as $pattern) {
            $expressions[] = $this->globToRegexp($pattern);
        }
        $regExp = '#^' . $this->globToRegexp($sourceRoot . '/').'(('.implode(')|(', $expressions).'))$#';

        // Build directory iterator
        $directoryIterator = new RecursiveDirectoryIterator(
            $sourceRoot,
            FilesystemIterator::SKIP_DOTS
                | FilesystemIterator::UNIX_PATHS
                | FilesystemIterator::KEY_AS_PATHNAME
                | FilesystemIterator::CURRENT_AS_FILEINFO
        );

        // Return filtered iterator
        $iterator = new RecursiveIteratorIterator($directoryIterator);
        return new RegexIterator($iterator, $regExp);
    }
protected function getFileIterator ( $ sourceRoot , $ patterns ) { // Build regexp pattern $ expressions = [ ] ; foreach ( $ patterns as $ pattern ) { $ expressions [ ] = $ this -> globToRegexp ( $ pattern ) ; } $ regExp = '#^' . $ this -> globToRegexp ( $ sourceRoot . '/' ) . '((' . implode ( ')|(' , $ expressions ) . '))$#' ; // Build directory iterator $ directoryIterator = new RecursiveDirectoryIterator ( $ sourceRoot , FilesystemIterator :: SKIP_DOTS | FilesystemIterator :: UNIX_PATHS | FilesystemIterator :: KEY_AS_PATHNAME | FilesystemIterator :: CURRENT_AS_FILEINFO ) ; // Return filtered iterator $ iterator = new RecursiveIteratorIterator ( $ directoryIterator ) ; return new RegexIterator ( $ iterator , $ regExp ) ; }
Get iterator of matching source files to copy

@param string $sourceRoot Root directory of sources (no trailing slash)
@param array $patterns List of wildcard patterns to match
@return Iterator File iterator, where key is path and value is file info object
Get iterator of matching source files to copy