typo3: list files in folder without asking the FAL driver

revision 80b6c1626b57989d5f5da927b7f0c5ede6bcb827

raw

phork0.txt

/* @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->settings['damDeckPlanFolderId']
);
$storage = $rf->getStorageObject($storageUid, array(), $folderId);
$folder  = $rf->createFolderObject($storage, $folderId, $folderId);

$arFileRows = $fir->findByFolder($folder);
if (count($arFileRows) > 0) {
    //we have files in our index - use them
    $arFiles = array();
    foreach ($arFileRows as $arRow) {
        $arFiles[] = $rf->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->retrieveFileOrFolderObject(
        $this->settings['damDeckPlanFolderId']
    );
    $arFiles = $folder->getFiles();
}

// .. do something with the files

History