class TimeZoneCacheContext in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Cache/Context/TimeZoneCacheContext.php \Drupal\Core\Cache\Context\TimeZoneCacheContext
- 9 core/lib/Drupal/Core/Cache/Context/TimeZoneCacheContext.php \Drupal\Core\Cache\Context\TimeZoneCacheContext
Defines the TimeZoneCacheContext service, for "per time zone" caching.
Cache context ID: 'timezone'.
Hierarchy
- class \Drupal\Core\Cache\Context\TimeZoneCacheContext implements CacheContextInterface
Expanded class hierarchy of TimeZoneCacheContext
See also
\Drupal\Core\Session\AccountProxy::setAccount()
1 string reference to 'TimeZoneCacheContext'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses TimeZoneCacheContext
File
- core/
lib/ Drupal/ Core/ Cache/ Context/ TimeZoneCacheContext.php, line 14
Namespace
Drupal\Core\Cache\ContextView source
class TimeZoneCacheContext implements CacheContextInterface {
/**
* {@inheritdoc}
*/
public static function getLabel() {
return t("Time zone");
}
/**
* {@inheritdoc}
*/
public function getContext() {
// date_default_timezone_set() is called in AccountProxy::setAccount(), so
// we can safely retrieve the timezone.
return date_default_timezone_get();
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TimeZoneCacheContext:: |
public | function |
Gets the cacheability metadata for the context. Overrides CacheContextInterface:: |
|
TimeZoneCacheContext:: |
public | function |
Returns the string representation of the cache context. Overrides CacheContextInterface:: |
|
TimeZoneCacheContext:: |
public static | function |
Returns the label of the cache context. Overrides CacheContextInterface:: |