Example #1
0
 /**
  * get all files with included filetypes from given directory and all subdirectories
  * that are not in a subdirectory from the excluded directory list.
  *
  * @param string $dir
  *
  * @return array
  */
 private function getFilesFromDir($dir)
 {
     $files = [];
     if ($handle = $this->filesystem->openDirectory($dir)) {
         while (false !== ($file = $this->filesystem->readdir($handle))) {
             if ($file != '.' && $file != '..') {
                 $fullPath = $dir . DIRECTORY_SEPARATOR . $file;
                 if ($this->filesystem->isDir($fullPath)) {
                     if (!$this->isDirectoryExcluded($fullPath)) {
                         $files[] = $this->getFilesFromDir($fullPath);
                     }
                 } elseif ($this->isFiletypeIncluded($file)) {
                     $files[] = $this->filesystem->realpath($fullPath);
                 }
             }
         }
         $this->filesystem->closeDirectory($handle);
     }
     return $this->array_flat($files);
 }