Project

General

Profile

Actions

Feature #93209

closed

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

Added by Ingo Reuter almost 4 years ago. Updated over 3 years 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);
}
Actions #1

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

Actions #2

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

Actions #3

Updated by Benni Mack over 3 years ago

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

Updated by Benni Mack over 3 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF