Feature #93209

Add getFile() to TYPO3\CMS\Core\Resource\Folder

Added by Ingo Reuter 9 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2021-01-03
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
Complexity:
easy
Sprint Focus:

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);
}
#1

Updated by Gerrit Code Review 8 months 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

#2

Updated by Gerrit Code Review 5 months 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

#3

Updated by Benni Mack 5 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#4

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF