class AssetQueryString
Same name in other branches
- 11.x core/lib/Drupal/Core/Asset/AssetQueryString.php \Drupal\Core\Asset\AssetQueryString
Stores a cache busting query string service for asset URLs.
The string changes on every update or full cache flush, forcing browsers to load a new copy of the files, as the URL changed.
Hierarchy
- class \Drupal\Core\Asset\AssetQueryString implements \Drupal\Core\Asset\AssetQueryStringInterface
Expanded class hierarchy of AssetQueryString
2 files declare their use of AssetQueryString
- AssetQueryStringTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Asset/ AssetQueryStringTest.php - State.php in core/
lib/ Drupal/ Core/ State/ State.php
1 string reference to 'AssetQueryString'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses AssetQueryString
File
-
core/
lib/ Drupal/ Core/ Asset/ AssetQueryString.php, line 16
Namespace
Drupal\Core\AssetView source
class AssetQueryString implements AssetQueryStringInterface {
/**
* The key used for state.
*/
const STATE_KEY = 'asset.css_js_query_string';
/**
* Creates a new AssetQueryString instance.
*
* @param \Drupal\Core\State\StateInterface $state
* State service.
* @param \Drupal\Component\Datetime\TimeInterface $time
* System time service.
*/
public function __construct(StateInterface $state, TimeInterface $time) {
}
/**
* {@inheritdoc}
*/
public function reset() : void {
// The timestamp is converted to base 36 in order to make it more compact.
$this->state
->set(self::STATE_KEY, base_convert(strval($this->time
->getRequestTime()), 10, 36));
}
/**
* {@inheritdoc}
*/
public function get() : string {
return $this->state
->get(self::STATE_KEY, '0');
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
AssetQueryString::get | public | function | |
AssetQueryString::reset | public | function | |
AssetQueryString::STATE_KEY | constant | The key used for state. | |
AssetQueryString::__construct | public | function | Creates a new AssetQueryString instance. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.