class UrlPackage extends Package
Package that adds a base URL to asset URLs in addition to a version.
The package allows to use more than one base URLs in which case it randomly chooses one for each asset; it also guarantees that any given path will always use the same base URL to be nice with HTTP caching mechanisms.
When the request context is available, this package can choose the best base URL to use based on the current request scheme:
__construct(string|string[] $baseUrls, VersionStrategyInterface $versionStrategy, ContextInterface $context = null) | ||
string | getVersion(string $path) Returns the asset version for an asset. | from Package |
string | getUrl(string $path) Returns an absolute or root-relative public path. | |
ContextInterface | getContext() | from Package |
VersionStrategyInterface | getVersionStrategy() | from Package |
isAbsoluteUrl($url) | from Package | |
string | getBaseUrl(string $path) Returns the base URL for a path. | |
int | chooseBaseUrl(string $path) Determines which base URL to use for the given path. |
string|string[] | $baseUrls | Base asset URLs |
VersionStrategyInterface | $versionStrategy | |
ContextInterface | $context |
Returns the asset version for an asset.
string | $path | A path |
string | The version string |
Returns an absolute or root-relative public path.
string | $path | A path |
string | The public path |
ContextInterface |
VersionStrategyInterface |
$url |
Returns the base URL for a path.
string | $path |
string | The base URL |
Determines which base URL to use for the given path.
Override this method to change the default distribution strategy. This method should always return the same base URL index for a given path.
string | $path |
int | The base URL index for the given path |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Asset/UrlPackage.html