-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.7][Asset] Framework config to support custom version strategy #15554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sory but you have example, I dont know how "use a compiler pass to extract the version and version format parameters from the default static strategy my package is compiled with" |
@CaptainJojo You can find an example in symfony/symfony-docs#5489 |
Thx :) |
@xavierbriand if we allow to pass the service id of a version strategy, this should be the id of a fully configured service (configuring it would be the responsibility of the code defining the service). Taking a definition id and then trying to modify it to inject some extra configuration in it requires making some assumptions about the API of the service class, and creates many cases where it is very hard to decide what would be the right behavior.
why not ? Compiler passes are allowed to do that. |
@stof I agree. And thanks for the heads up on the compiler pass, my first attempt was unsuccessful. My point is it's inconvenient/unelegant/hacky to define your own strategy and/or have a different strategy for different packages. It might be that the default way constrict you in a specific pass (a version and version format, period) that is hard to deviate from. I'm not used to spend much time change/extend Sf's behavior. |
status on this? any solutions provided anywhere? |
Why not use tagged services to add packages ? like this: Or allow to add in config something like: framework:
assets:
packages:
some_name: @service_id |
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, the recommended solution is to:
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 default
assets.packages
service.It's neither convenient nor elegant.
I propose to add an optional parameter to set custom strategies:
A convenient abstract
BaseVersionStrategy
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 asset
base_urls
orbase_path
. Please provide your thoughts.The text was updated successfully, but these errors were encountered: