You are here

class IsSuperUserCacheContext in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Cache/Context/IsSuperUserCacheContext.php \Drupal\Core\Cache\Context\IsSuperUserCacheContext

Defines the IsSuperUserCacheContext service, for "super user or not" caching.

Cache context ID: 'user.is_super_user'.

Hierarchy

Expanded class hierarchy of IsSuperUserCacheContext

1 string reference to 'IsSuperUserCacheContext'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses IsSuperUserCacheContext
cache_context.user.is_super_user in core/core.services.yml
Drupal\Core\Cache\Context\IsSuperUserCacheContext

File

core/lib/Drupal/Core/Cache/Context/IsSuperUserCacheContext.php, line 17
Contains \Drupal\Core\Cache\Context\IsSuperUserCacheContext.

Namespace

Drupal\Core\Cache\Context
View source
class IsSuperUserCacheContext extends UserCacheContextBase implements CacheContextInterface {

  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t('Is super user');
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return (int) $this->user
      ->id() === 1 ? '1' : '0';
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata() {
    return new CacheableMetadata();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
IsSuperUserCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
IsSuperUserCacheContext::getContext public function Returns the string representation of the cache context. Overrides CacheContextInterface::getContext
IsSuperUserCacheContext::getLabel public static function Returns the label of the cache context. Overrides CacheContextInterface::getLabel
UserCacheContextBase::$user protected property The account object.
UserCacheContextBase::__construct public function Constructs a new UserCacheContextBase class. 1