@@ -63,8 +63,13 @@ any versioning::
63
63
64
64
$package = new Package(new EmptyVersionStrategy());
65
65
66
+ // Absolute path
66
67
echo $package->getUrl('/image.png');
67
68
// result: /image.png
69
+
70
+ // Relative path
71
+ echo $package->getUrl('image.png');
72
+ // result: image.png
68
73
69
74
Packages implement :class: `Symfony\\ Component\\ Asset\\ PackageInterface `,
70
75
which defines the following two methods:
@@ -105,8 +110,13 @@ suffix to any asset path::
105
110
106
111
$package = new Package(new StaticVersionStrategy('v1'));
107
112
113
+ // Absolute path
108
114
echo $package->getUrl('/image.png');
109
115
// result: /image.png?v1
116
+
117
+ // Relative path
118
+ echo $package->getUrl('image.png');
119
+ // result: image.png?v1
110
120
111
121
In case you want to modify the version format, pass a sprintf-compatible format
112
122
string as the second argument of the ``StaticVersionStrategy `` constructor::
@@ -122,6 +132,9 @@ string as the second argument of the ``StaticVersionStrategy`` constructor::
122
132
123
133
echo $package->getUrl('/image.png');
124
134
// result: /v1/image.png
135
+
136
+ echo $package->getUrl('image.png');
137
+ // result: v1/image.png
125
138
126
139
Custom Version Strategies
127
140
.........................
@@ -170,6 +183,10 @@ that path over and over again::
170
183
171
184
echo $package->getUrl('logo.png');
172
185
// result: /static/images/logo.png?v1
186
+
187
+ // Base path is ignored when using absolute paths
188
+ echo $package->getUrl('/logo.png');
189
+ // result: /logo.png?v1
173
190
174
191
Request Context Aware Assets
175
192
............................
0 commit comments