Open amazeika opened 7 years ago
Handle routing at render time by making use of the assets template filter. For inspiration check the code for the assets filter. It does the following:
'base://' => rtrim($this->getObject('request')->getBaseUrl()->getPath(), '/').'/'
To create your own asset you can just use the core filter with the base:// scheme or another option could be to add an additional filter in com:files and introduce a file:// scheme, which would allow you to do additional processing.
You could do things like
file://container/path
Where file will be replaced by the url path, container by the container path and the path would be pre-pended. This would move the responsibility to create the url for the file to the filter, the cool thing about this is that it would make moving files into a CDN very simple, you just extend the filter to rewrite the paths differently.
The idea is to have a mechanism to override routes of direct file URLs served by files, e.g. thumbnails. This allows each app running files to override how this paths are constructed at render time.
An implementation example is rendering thumbnails link on FILEman on Joomla vs Platform. Platform requires the web part of the path to be stripped as it's part of the document root.
NOTE
This filter is to replace this utility method https://github.com/joomlatools/joomlatools-framework-files/blob/master/filter/path.php#L117-L128
Make sure to remove this code and places where this is being used after implementation.