Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Description
The Framework bundle only implements two asset version strategies: empty and static (defaults provided by the Asset component).
If I want to use a custom strategy for my package (eg. to add the locale its path) without overriding the defaults, therecommended solution is to:
- create a new service (my strategy)
- use a compiler pass to extract the version and version format parameters from the default static strategy my package is compiled with
- update the definition of my service with previously extracted parameters
If I have two packages with the same custom strategy but different versions, I need to duplicate my service declaration and update my compiler. And I cannot create services on-demand during the compiler pass. I could also create my own package configuration for my bundle that would override or extend the defaultassets.packages service.
It's neither convenient nor elegant.
I propose to add an optional parameter to set custom strategies:
#app/config/config.ymlframework:#...assets:base_urls://my.cdn.compackages:pdf:version:%version%version_format:/name/space/%%2$s/pdf%%1$slocalized_doc:version:%version%version_strategy:my.abstract.service.id# default is assets.static_version_strategy falling back on assets.empty_version_strategy if version is null (current behavior)version_format:/name/space/%%2$s/doc/%%3$s%/abc%1$s#%3$s would be my locale
A convenient abstractBaseVersionStrategy class could be provided that would declaresetVersion andsetVersionFormat to inject said parameters.
This solves a particular problem I have where I want to inject known parameters in an assetbase_urls orbase_path. Please provide your thoughts.