You are here

class TimeZoneCacheContext in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 19
Contains \Drupal\Core\Cache\Context\TimeZoneCacheContext.

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

Namesort descending Modifiers Type Description Overrides
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