Feature #93209
closedAdd getFile() to TYPO3\CMS\Core\Resource\Folder
100%
Description
Working with Files and Folders in FAL is quite convenient. The class TYPO3\CMS\Core\Resource\Folder
offers many methods for getting folders and files inside a specific folder.
The class allows to retrieve a list of all files inside a folder, a list of subfolders, to create a new file inside the folder and many more. It is even possible to get a specific folder inside the current folder (via $folder->getSubfolder("folderName")
). Unfortunately the equivalent method does not exist for files. It would be handy to have something like $folder->getFile("filename.ext")
instead of calling $folder->getStorage()->getFileInFolder("filename.ext", $folder)
. It might be mentioned, that the method hasFile(..)
is already implemented.
My suggestion is to add the following method to TYPO3\CMS\Core\Resource\Folder
public function getFile($fileName) {
if (!$this->storage->hasFileInFolder($fileName, $this)) {
throw new \InvalidArgumentException('File "' . $fileName . '" does not exist in "' . $this->identifier . '"', 1609714577);
}
return $this->storage->getFileInFolder($fileName, $this);
}
Updated by Gerrit Code Review almost 4 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67433
Updated by Gerrit Code Review over 3 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67433
Updated by Benni Mack over 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset a85bac036a3f096af559d85c387f76aa7bcdca31.