-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1093,8 +1093,61 @@ version_strategy | |
|
||
**type**: ``string`` **default**: ``null`` | ||
|
||
The service id of the :doc:`asset version strategy </frontend/custom_version_strategy>` | ||
applied to the assets. | ||
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``. | ||
|
||
The ``assets.empty_version_strategy`` is useful to override the global asset | ||
versioning strategy inside an asset package: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
# app/config/config.yml | ||
framework: | ||
assets: | ||
# this strategy is applied to every asset (including packages) ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
version_strategy: 'app.asset.my_versioning_strategy' | ||
packages: | ||
foo_package: | ||
# ... except if a package explicitly uses the empty strategy | ||
version_strategy: 'assets.empty_version_strategy' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
.. code-block:: xml | ||
|
||
<!-- app/config/config.xml --> | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<framework:config> | ||
<framework:assets version_strategy="app.asset.my_versioning_strategy"> | ||
<framework:package | ||
name="foo_package" | ||
version-strategy="assets.empty_version_strategy" /> | ||
</framework:assets> | ||
</framework:config> | ||
</container> | ||
|
||
.. code-block:: php | ||
|
||
// app/config/config.php | ||
$container->loadFromExtension('framework', array( | ||
'assets' => array( | ||
'version_strategy' => 'app.asset.my_versioning_strategy', | ||
'packages' => array( | ||
'foo_package' => array( | ||
// ... | ||
'version_strategy' => 'assets.empty_version_strategy', | ||
), | ||
), | ||
), | ||
)); | ||
|
||
.. note:: | ||
|
||
|
There was a problem hiding this comment.
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 inversion_strategy
. If you want to use a static version, use theversion
setting (with a non-empty value) instead (which will create a child service configured with this version)