<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/* @var $rf \TYPO3\CMS\Core\Resource\ResourceFactory */
$rf = GeneralUtility::makeInstance(
    'TYPO3\\CMS\\Core\\Resource\\ResourceFactory'
);
/* @var $fir \TYPO3\CMS\Core\Resource\Index\FileIndexRepository */
$fir = GeneralUtility::makeInstance(
    'TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository'
);

// we create a folder object without checking that the folder
// actually exists, since we need it for the index only.
list($storageUid, $folderId) = explode(
    ':', $this-&gt;settings['damDeckPlanFolderId']
);
$storage = $rf-&gt;getStorageObject($storageUid, array(), $folderId);
$folder  = $rf-&gt;createFolderObject($storage, $folderId, $folderId);

$arFileRows = $fir-&gt;findByFolder($folder);
if (count($arFileRows) &gt; 0) {
    //we have files in our index - use them
    $arFiles = array();
    foreach ($arFileRows as $arRow) {
        $arFiles[] = $rf-&gt;getFileObject($arRow['uid'], $arRow);
    }
} else {
    //we do not have any files in the index of the folder
    // better fetch the files from DAM directly

    /* @var $folder \TYPO3\CMS\Core\Resource\Folder*/
    $folder = $rf-&gt;retrieveFileOrFolderObject(
        $this-&gt;settings['damDeckPlanFolderId']
    );
    $arFiles = $folder-&gt;getFiles();
}

// .. do something with the files</pre></body></html>