Blueprint: Static Resources in FAL
|Proposal||Implement a proper way to address files within packages in FAL|
|Status||Draft, Discussion, Voting Phase, Accepted, Declined, Withdrawn|
|Current Progress||Unknown, Started, Good Progress, Bad Progress, Stalled, Review Needed|
|Topic for Gerrit||###gerrit_topic###|
- Started during TYPO3 CMS 7.1 development
Goals / Motivation
A "static resource" is a file always within a package, and not within a storage. It is always addressed with the full package as name (not via the extension), and implements some similar methods as the regular, already known FAL Resource object. The file (for now) is always located locally, so local implementations can be used directly.
A StaticResourceRepository is responsible for creating / handling the objects.
The main idea is to address the downsides of the current logic (BACK_PATH, extRelPath, Paths with EXT:) and integrate a FAL-principled-logic for these files.
- Should be used to get (and write) content and paths for files within packages - Should be used for all places within the Core where Assets / Resources from Packages are needed - NOT used for Temporary Data (typo3temp/ or uploads/), ALWAYS related to a Package - no DB needed, no tracking of files in DB / size / indexing - TODO: How to deal with scaling/IM functionality for these files? Do we do this at all? - Files not within a Package (yet) need to be handled manually (gfx/ backend.php, init.php etc) - Future idea: With this concept We could move the packages out of the Web folder by using passthrough() functions
What is then left for storage=0 are files that are inside typo3temp/ (also e.g. Gifbuilder) and uploads/
We have two classes "StaticResource" and "StaticResourceManager"
- get($packageName, $fileName) Replaces: getAbsoluteFile... Replaces: $BACK_PATH / extRelPath... - getAllnPath($packageName, $fileName) Replaces: GeneralUtility::getFilesInDir() - add($packageName, $fileName, $content, $overrideMode) - delete($packageName, $fileName)
- getFilesize() - getMimetype() - getFileextension() - getCreationtime() - getModificationtime() - getFullPath() used for getting the full path on the file system - getPublicUrl() used for output and for linking, always absolute to the site (e.g. returns /typo3/sysext/core/Resources/Private/Templates/Main/MyTemplate.html) - getContents() - setContents() (writes immediately)