public function addDirectory($path, $recursive = true)
    {
        if (realpath($path) === false || !is_dir(realpath($path))) {
            throw new FileNotFoundException(sprintf("Directory '%s' not found.", $path));
        }

        $finder = new Finder();
        $finder->files()->name('*.yml')->depth($recursive ? '>= 0' : '== 0')->in($path)->sortByName();
        foreach ($finder as $file) {
            /** @var \SplFileInfo $file */
            $this->addFile($file->getRealpath());
        }

        return $this;
    }
public function addDirectory($path, $recursive = true)
    {
        if (realpath($path) === false || !is_dir(realpath($path))) {
            throw new FileNotFoundException(sprintf("Directory '%s' not found.", $path));
        }

        $finder = new Finder();
        $finder->files()->name('*.yml')->depth($recursive ? '>= 0' : '== 0')->in($path)->sortByName();
        foreach ($finder as $file) {
            /** @var \SplFileInfo $file */
            $this->addFile($file->getRealpath());
        }

        return $this;
    }
public function addDirectory ( $ path , $ recursive = true ) { if ( realpath ( $ path ) === false || ! is_dir ( realpath ( $ path ) ) ) { throw new FileNotFoundException ( sprintf ( "Directory '%s' not found." , $ path ) ) ; } $ finder = new Finder ( ) ; $ finder -> files ( ) -> name ( '*.yml' ) -> depth ( $ recursive ? '>= 0' : '== 0' ) -> in ( $ path ) -> sortByName ( ) ; foreach ( $ finder as $ file ) { /** @var \SplFileInfo $file */ $ this -> addFile ( $ file -> getRealpath ( ) ) ; } return $ this ; }
Add directory with yml files to load

<code>
$loader->addDirectory('/path/to/fixtures');
$loader->addDirectory('/path/to/fixtures', false);
</code>

@author Vincent CHALAMON <vincentchalamon@gmail.com>

@param string  $path      Path name with yml files
@param boolean $recursive Read path recursively

@return YamlFixturesLoader    Loader
@throws FileNotFoundException File doesn't exist
Add directory with yml files to load