Skip to content

Commit 5f431ef

Browse files
committed
Improved the explanation of "version_strategy" option
1 parent a638610 commit 5f431ef

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

reference/configuration/framework.rst

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,61 @@ version_strategy
10931093

10941094
**type**: ``string`` **default**: ``null``
10951095

1096-
The service id of the :doc:`asset version strategy </frontend/custom_version_strategy>`
1097-
applied to the assets.
1096+
The service id of the asset version strategy applied to the assets. In addition
1097+
to your own :doc:`custom asset version strategies </frontend/custom_version_strategy>`,
1098+
Symfony defines two services for its :ref:`built-in strategies <component-assets-versioning>`:
1099+
``assets.empty_version_strategy`` and ``assets.static_version_strategy``.
1100+
1101+
The ``assets.empty_version_strategy`` is useful to override the global asset
1102+
versioning strategy inside an asset package:
1103+
1104+
.. configuration-block::
1105+
1106+
.. code-block:: yaml
1107+
1108+
# app/config/config.yml
1109+
framework:
1110+
assets:
1111+
# this strategy is applied to every asset (including packages) ...
1112+
version_strategy: 'app.asset.my_versioning_strategy'
1113+
packages:
1114+
foo_package:
1115+
# ... except if a package explicitly uses the empty strategy
1116+
version_strategy: 'assets.empty_version_strategy'
1117+
1118+
.. code-block:: xml
1119+
1120+
<!-- app/config/config.xml -->
1121+
<?xml version="1.0" encoding="UTF-8" ?>
1122+
<container xmlns="http://symfony.com/schema/dic/services"
1123+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1124+
xmlns:framework="http://symfony.com/schema/dic/symfony"
1125+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
1126+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
1127+
1128+
<framework:config>
1129+
<framework:assets version_strategy="app.asset.my_versioning_strategy">
1130+
<framework:package
1131+
name="foo_package"
1132+
version-strategy="assets.empty_version_strategy" />
1133+
</framework:assets>
1134+
</framework:config>
1135+
</container>
1136+
1137+
.. code-block:: php
1138+
1139+
// app/config/config.php
1140+
$container->loadFromExtension('framework', array(
1141+
'assets' => array(
1142+
'version_strategy' => 'app.asset.my_versioning_strategy',
1143+
'packages' => array(
1144+
'foo_package' => array(
1145+
// ...
1146+
'version_strategy' => 'assets.empty_version_strategy',
1147+
),
1148+
),
1149+
),
1150+
));
10981151
10991152
.. note::
11001153

0 commit comments

Comments
 (0)