Translations
Info
All page names need to be in English.
en da  de  fr  it  ja  km  nl  ru  zh

Blueprints/FAL-StaticResources

From TYPO3Wiki
Jump to: navigation, search

<- Back to blueprints overview

Blueprint: Static Resources in FAL

Proposal Implement a proper way to address files within packages in FAL
Owner/Starter Benni Mack
Participants/Members -
Status Draft, Discussion, Voting Phase, Accepted, Declined, Withdrawn
Current Progress Unknown, Started, Good Progress, Bad Progress, Stalled, Review Needed
Topic for Gerrit ###gerrit_topic###

Target Versions/Milestones

  • Started during TYPO3 CMS 7.1 development

Goals / Motivation

In order to find a general way to handle assets and files like CSS/JavaScript files used for the Backend, and Template files within extensions, that are basically located within any package, the name "Static Resource" is created. All files that are within extensions and system extensions can be addressed then. This makes it possible to e.g. link to icons without using a back path (which is still needed throughout the backend right now), and to get rid of the EXT: syntax for templates.

Concept

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.

Principal design:

 - 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/

Implementation Details

We have two classes "StaticResource" and "StaticResourceManager"

StaticResourceRepository

 - get($packageName, $fileName)
     Replaces: getAbsoluteFile...
     Replaces: $BACK_PATH / extRelPath...
 - getAllnPath($packageName, $fileName)
     Replaces: GeneralUtility::getFilesInDir()
 - add($packageName, $fileName, $content, $overrideMode)
 - delete($packageName, $fileName)

StaticResource

 - 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)

Risks

Issues and reviews

Dependencies upon other Blueprints

External links for clarification of technologies