class TimeZoneCacheContext

Same name in other branches
  1. 9 core/lib/Drupal/Core/Cache/Context/TimeZoneCacheContext.php \Drupal\Core\Cache\Context\TimeZoneCacheContext
  2. 10 core/lib/Drupal/Core/Cache/Context/TimeZoneCacheContext.php \Drupal\Core\Cache\Context\TimeZoneCacheContext
  3. 11.x 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

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
cache_context.timezone in core/core.services.yml
Drupal\Core\Cache\Context\TimeZoneCacheContext

File

core/lib/Drupal/Core/Cache/Context/TimeZoneCacheContext.php, line 14

Namespace

Drupal\Core\Cache\Context
View 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

Title Sort descending Modifiers Object type Summary Overriden Title
TimeZoneCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
TimeZoneCacheContext::getContext public function Returns the string representation of the cache context. Overrides CacheContextInterface::getContext
TimeZoneCacheContext::getLabel public static function Returns the label of the cache context. Overrides CacheContextInterface::getLabel

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.