Skip to content

Improved the explanation of "version_strategy" option #7519

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

Closed
wants to merge 3 commits into from

Conversation

javiereguiluz
Copy link
Member

The idea to improve this came from symfony/symfony#21683

packages:
foo_package:
# ... except if a package explicitly uses the empty strategy
version_strategy: 'assets.empty_version_strategy'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to use the empty version strategy, a better solution is to configure the version as empty rather than overwriting the strategy IMO. It avoids relying on the service id used in FrameworkBundle (se my comment in the symfony issue)

# app/config/config.yml
framework:
assets:
# this strategy is applied to every asset (including packages) ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this strategy is applied to all assets of the default package, and to all custom packages, unless they configure their own version or their own version strategy

The service id of the asset version strategy applied to the assets. In addition
to your own :doc:`custom asset version strategies </frontend/custom_version_strategy>`,
Symfony defines two services for its :ref:`built-in strategies <component-assets-versioning>`:
``assets.empty_version_strategy`` and ``assets.static_version_strategy``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assets.static_version_strategy is not usable directly. It is an abstract service. So you cannot use it directly in version_strategy. If you want to use a static version, use the version setting (with a non-empty value) instead (which will create a child service configured with this version)

@javiereguiluz
Copy link
Member Author

@stof thanks for your review! I've changed everything and I think it's better now.

version: ~
bar_package:
# this package doesn't use the global versioning strategy
version_strategy: 'app.asset.another_version_strategy'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a third part not redefining the version or strategy (but changing the base URL for instance), with a comment explaining that it inherits the default strategy, to make it easier to understand. What do you think about it ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I've done that in 7b09de0. Thanks!

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@HeahDude HeahDude added this to the 3.1 milestone Apr 15, 2017
@xabbuh
Copy link
Member

xabbuh commented Apr 15, 2017

Thank you Javier.

xabbuh added a commit that referenced this pull request Apr 15, 2017
…viereguiluz)

This PR was submitted for the 3.1 branch but it was merged into the 3.2 branch instead (closes #7519).

Discussion
----------

Improved the explanation of "version_strategy" option

The idea to improve this came from symfony/symfony#21683

Commits
-------

9405e65 Improved the explanation of "version_strategy" option
xabbuh added a commit that referenced this pull request Apr 15, 2017
@xabbuh xabbuh closed this Apr 15, 2017
weaverryan added a commit that referenced this pull request Apr 15, 2017
* 3.2: (71 commits)
  Rewriting the service container docs
  Minor reword
  Adding a tip for validation in forms without class
  [#7217] add versionadded directives
  [#7203] merge note and versionadded directive
  Use the new configurator YAML syntax
  Added a note about the .htaccess files included by Symfony apps
  Made unmapped field example in forms chapter more descriptive
  [#7507] fix namespace
  [#7507] fix component name
  [#7490] minor typo fix
  Added a note about redirections to absolute URLs in tests
  [#7204] link to API doc
  Added docs for JsonResponse::fromJsonString
  Added the changes suggested by reviewers
  [#7620] use generate() in PHP templates before 2.8
  Fixed the RST syntax
  Improve example context
  Minor formatting changes
  [#7519] some minor tweaks
  ...
@javiereguiluz javiereguiluz deleted the asset_versioning branch May 24, 2018 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants