class TimeZoneCacheContext

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

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.