Skip to content

Commit

Permalink
Merge pull request #55 from humanmade/fix/directory-iteration
Browse files Browse the repository at this point in the history
Switch to a recursive directory iterator for the file fetcher
  • Loading branch information
tcrsavage committed Mar 21, 2019
2 parents b83b881 + 51a4706 commit bf5cc1f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions inc/classes/iterator/files/class-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ protected function get_files_in_path() {
}

if ( is_dir( $path_found ) ) {
$iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path_found ) );
$files = [];

$files = array_map( function( $item ) use ( $path_found ) {

return $path_found . '/' . $item;

}, scandir( $path_found ) );

foreach ( $iterator as $pointer ) {
if ( ! $pointer->isDir() ) {
$files[] = $pointer->getPathname();
}
}
} else {

$files = [ $path_found ];
Expand Down

0 comments on commit bf5cc1f

Please sign in to comment.