Convert file list to a single array

@param aray $fileList
@param bool $onlyFileType [null, true, false] - Filter for type of files/directories.
@param string $parentDirName

@return aray
351087
protected function getSingeFileList(array $fileList, $onlyFileType = null, $basePath = null, $parentDirName = '')
    {
        $singleFileList = array();
        foreach($fileList as $dirName => $fileName) {

            if (is_array($fileName)) {
                $currentDir = Utils\Util::concatPath($parentDirName, $dirName);

                if (!isset($onlyFileType) || $onlyFileType == $this->isFile($currentDir, $basePath)) {
                    $singleFileList[] = $currentDir;
                }

                $singleFileList = array_merge($singleFileList, $this->getSingeFileList($fileName, $onlyFileType, $basePath, $currentDir));

            } else {
                $currentFileName = Utils\Util::concatPath($parentDirName, $fileName);

                if (!isset($onlyFileType) || $onlyFileType == $this->isFile($currentFileName, $basePath)) {
                    $singleFileList[] = $currentFileName;
                }
            }
        }

        return $singleFileList;
    }
500169
protected function getBoundaryAndChildStreams(ParentHeaderPart $part)
    {
        $boundary = $part->getHeaderParameter('Content-Type', 'boundary');
        if ($boundary === null) {
            return array_map(
                function ($child) {
                    return $child->getStream();
                },
                $part->getChildParts()
            );
        }
        $streams = [];
        foreach ($part->getChildParts() as $i => $child) {
            if ($i !== 0 || $part->hasContent()) {
                $streams[] = Psr7\stream_for("\r\n");
            }
            $streams[] = Psr7\stream_for("--$boundary\r\n");
            $streams[] = $child->getStream();
        }
        $streams[] = Psr7\stream_for("\r\n--$boundary--\r\n");
        
        return $streams;
    }
439352
protected function parentInList($parentId, $list)
    {
        foreach ($list as $node) {
            if ($parentId === $node->getNodeId()) {
                return true;
            }
        }

        return false;
    }
397016
final private static function getDirectoryStructureDo($relativePath, $rootDirectory, $exclude3rdParty)
    {
        $thisRoot = $rootDirectory;
        if ($relativePath !== '') {
            $thisRoot .= '/'.$relativePath;
        }
        $subDirs = array();
        $hDir = @opendir($thisRoot);
        if ($hDir === false) {
            throw new \Exception("Unable to open directory $rootDirectory");
        }
        while (($entry = @readdir($hDir)) !== false) {
            if ($entry[0] === '.') {
                continue;
            }
            $fullPath = $thisRoot.'/'.$entry;
            if (!is_dir($fullPath)) {
                continue;
            }
            if ($exclude3rdParty) {
                if (($entry === 'vendor') || preg_match('%/libraries/3rdparty$%', $fullPath)) {
                    continue;
                }
            }
            $subDirs[] = $entry;
        }
        @closedir($hDir);
        $result = array();
        foreach ($subDirs as $subDir) {
            $rel = ($relativePath === '') ? $subDir : "$relativePath/$subDir";
            $result = array_merge($result, static::getDirectoryStructureDo($rel, $rootDirectory, $exclude3rdParty));
            $result[] = $rel;
        }

        return $result;
    }
129531
private function getMutationsFromFile(SplFileInfo $file, bool $onlyCovered, array $extraNodeVisitors): array
    {
        try {
            /** @var Node[] $initialStatements */
            $initialStatements = $this->parser->parse($file->getContents());
        } catch (\Throwable $t) {
            throw ParserException::fromInvalidFile($file, $t);
        }

        $traverser = new PriorityNodeTraverser();
        $filePath = $file->getRealPath();
        \assert(\is_string($filePath));

        $mutationsCollectorVisitor = new MutationsCollectorVisitor(
            $this->mutators,
            $filePath,
            $initialStatements,
            $this->codeCoverageData,
            $onlyCovered
        );

        $traverser->addVisitor(new NotMutableIgnoreVisitor(), 50);
        $traverser->addVisitor(new ParentConnectorVisitor(), 40);
        $traverser->addVisitor(new FullyQualifiedClassNameVisitor(), 30);
        $traverser->addVisitor(new ReflectionVisitor(), 20);
        $traverser->addVisitor($mutationsCollectorVisitor, 10);

        foreach ($extraNodeVisitors as $priority => $visitor) {
            $traverser->addVisitor($visitor, $priority);
        }

        $traverser->traverse($initialStatements);

        return $mutationsCollectorVisitor->getMutations();
    }
1136018
public function addFilelist(FileList $fl)
    {
        if ($this->isReference()) {
            throw $this->noChildrenAllowed();
        }
        $this->elements[] = $fl;
        $this->checked = false;
    }
802721
public static function getAccessTreeByParentId($isSuper, $menuIdList, $parentId, $condition = '', $params = [], $order = 'display_order asc')
    {
        $data = static::find()
            ->active()
            ->findByParentId($parentId)
            ->andWhere($condition, $params)
            ->orderBy($order)
            ->all();
        $tree = [];
        if ($data) {
            foreach ($data as $item) {
                if ($isSuper || in_array($item['menu_id'], $menuIdList)) {
                    $node = [
                        'menu_id' => $item['menu_id'],
                        'parent_id' => $item['parent_id'],
                        'tab_id' => 'tab_' . $item['menu_id'],
                        'text' => $item['text'],
                        'origin_text' => $item['text'],
                        'title' => $item['title'],
                        'url' => $item['url'],
                        'view_package' => $item['view_package'],
                        'expanded' => (bool) $item['expanded'],
                        'is_expand' => (bool) $item['expanded'],
                        'closable' => (bool) $item['closable'],
                        'is_open_url' => (bool) $item['is_open_url'],
                        'is_open_target' => (bool) $item['is_open_target'],
                        'is_every_open' => (bool) $item['is_every_open'],
                        'is_hide' => (bool) $item['is_hide'],
                        'display_order' => $item['display_order'],
                        'params' => $item['params'],
                        'note' => $item['note'],
                        'status' => intval($item['status']),
                    ];
                    $children = static::getAccessTreeByParentId($isSuper, $menuIdList, $item['menu_id'], $condition, $params, $order);
                    if ($children) {
                        $node['leaf'] = false;
                        $node['children'] = $children;
                    } else {
                        $node['leaf'] = true;
                    }
                    $tree[] = $node;
                }
            }
        }

        return $tree;
    }
1336255
public function toArray($filePath = null, string $disk = null, string $readerType = null): array
    {
        $filePath = $this->getFilePath($filePath);

        return $this->getImporter()->toArray(
            $this,
            $filePath,
            $disk ?? $this->disk ?? null,
            $readerType ?? $this->readerType ?? null
        );
    }
1147715
public function saveImageAjaxAction($parentId, $parentType)
    {
        $config = FileConfiguration::getImageConfig();
        return $this->saveFileAjaxAction(
            $parentId,
            $parentType,
            $config['objectType'],
            $config['validMimeTypes'],
            $config['extBlackList']
        );
    }
362964
private function buildFileList($directories = [], $fileList = [])
    {
        $output = [];
        foreach ($directories as $directory) {
            foreach ($fileList as $file) {
                $fileName = $directory . DIRECTORY_SEPARATOR . $file;

                if (is_file($fileName) && is_readable($fileName)) {
                    $output[] = $fileName;
                }
            }
        }

        return $output;
    }
169038
function onlyDirectories ()
  {
    return $this->where (function ($f) {
      if (!is_object ($f) || !$f instanceof SplFileInfo)
        throw new \RuntimeException ("You must use FilesystemIterator::CURRENT_AS_PATHNAME with onlyDirectories() ");
      return $f->isDir ();
    });
  }
873665
protected function getCategoryLevel($parentCategoryId, \Category $parentCategory=null, \DmsLoaderParams $params)
  {
    $arrCategories = array();
    $objCategory = $this->Database->prepare("SELECT * FROM tl_dms_categories WHERE pid = ? ORDER BY sorting")
                    ->execute($parentCategoryId);
    
    $category = null;
    while ($objCategory->next())
    {
      $category = $this->buildCategory($objCategory);
      $category->parentCategory = $parentCategory;
      $category->subCategories = $this->getCategoryLevel($category->id, $category, $params);
      if ($params->loadAccessRights)
      {
        $category->accessRights = $this->getAccessRights($category, $params);
      }
      if ($params->loadDocuments)
      {
        $category->documents = $this->getDocuments($category, $params);
      }
      $arrCategories[$category->id] = $category;
    }

    return $arrCategories;
  }
1238290
protected function scanDirectory(string $path, string $parentDir): array
    {
        $files = [];

        $rdi = new \RecursiveDirectoryIterator(
            $path,
            \FilesystemIterator::SKIP_DOTS |
            \FilesystemIterator::KEY_AS_FILENAME |
            \FilesystemIterator::CURRENT_AS_FILEINFO
        );

        $rii = new \RecursiveIteratorIterator($rdi);

        $needle = Constants::DS.$parentDir.Constants::DS;
        $len = \strlen($needle);
        foreach ($rii as $fileInfo) {
            $path = $fileInfo->getPathname();
            $pos = \strrpos($path, $needle);
            $files[] = \substr($path, $pos + $len);
        }

        return $files;
    }
442340
protected function buildFolderTree($parent, $visible, $level, $maxLevel, $exclude, &$resultsList)
    {
        if ($level > $maxLevel) {
            return;
        }

        $search = FolderQuery::create();

        $this->configureI18nProcessing($search, array(
                    'TITLE'
                ));

        $search->filterByParent($parent);

        if ($visible != BooleanOrBothType::ANY) {
            $search->filterByVisible($visible);
        }

        if ($exclude != null) {
            $search->filterById($exclude, Criteria::NOT_IN);
        }

        $search->orderByPosition(Criteria::ASC);

        $results = $search->find();

        foreach ($results as $result) {
            $resultsList[] = array(
                "ID" => $result->getId(),
                "TITLE" => $result->getVirtualColumn('i18n_TITLE'),
                "PARENT" => $result->getParent(),
                "URL" => $this->getReturnUrl() ? $result->getUrl($this->locale) : null,
                "VISIBLE" => $result->getVisible() ? "1" : "0",
                "LEVEL" => $level,
                'CHILD_COUNT' => $result->countChild(),
            );

            $this->buildFolderTree($result->getId(), $visible, 1 + $level, $maxLevel, $exclude, $resultsList);
        }
    }
271726
public function fromArray(array $fromArray): DirectoryItem
    {
        $typeExists = array_key_exists('type', $fromArray);
        $dirExists = array_key_exists('dir', $fromArray);

        if ($typeExists === false && $dirExists === true && is_bool($fromArray['dir'])) {
            $fromArray['type'] = $fromArray['dir'] === true ? self::TYPE_DIR : self::TYPE_FILE;
        }

        /**
         * @var self $dirItem
         */
        $dirItem = parent::fromArray($fromArray);

        return $dirItem;
    }
196270
public function getFileSystemFiles( $relative_path, $only_dirs = false )
	{
		$files = array();

		// Extract directories:
		$iterator = new \DirectoryIterator( ROOT_PATH . "/$relative_path" );

		foreach ( $iterator as $file_info )
		{
			$file = $file_info->getFilename();

			// Exclude .svn, .cache and any other file starting with .
			if ( 0 !== strpos( $file, '.' ) )
			{
				if ( !$only_dirs || $file_info->isDir() )
				{
					$files[] = $file;
				}
			}
		}

		return $files;
	}
639660
private void listDirectory(File directory,
                               RelativeDirectory subdirectory,
                               Set<JavaFileObject.Kind> fileKinds,
                               boolean recurse,
                               ListBuffer<JavaFileObject> resultList) {
        File d = subdirectory.getFile(directory);
        if (!caseMapCheck(d, subdirectory))
            return;

        File[] files = d.listFiles();
        if (files == null)
            return;

        if (sortFiles != null)
            Arrays.sort(files, sortFiles);

        for (File f: files) {
            String fname = f.getName();
            if (f.isDirectory()) {
                if (recurse && SourceVersion.isIdentifier(fname)) {
                    listDirectory(directory,
                                  new RelativeDirectory(subdirectory, fname),
                                  fileKinds,
                                  recurse,
                                  resultList);
                }
            } else {
                if (isValidFile(fname, fileKinds)) {
                    JavaFileObject fe =
                        new RegularFileObject(this, fname, new File(d, fname));
                    resultList.append(fe);
                }
            }
        }
    }