class IsSuperUserCacheContext in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Cache/Context/IsSuperUserCacheContext.php \Drupal\Core\Cache\Context\IsSuperUserCacheContext
- 10 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
- class \Drupal\Core\Cache\Context\UserCacheContextBase
- class \Drupal\Core\Cache\Context\IsSuperUserCacheContext implements CacheContextInterface
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
File
- core/
lib/ Drupal/ Core/ Cache/ Context/ IsSuperUserCacheContext.php, line 12
Namespace
Drupal\Core\Cache\ContextView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IsSuperUserCacheContext:: |
public | function |
Gets the cacheability metadata for the context. Overrides CacheContextInterface:: |
|
IsSuperUserCacheContext:: |
public | function |
Returns the string representation of the cache context. Overrides CacheContextInterface:: |
|
IsSuperUserCacheContext:: |
public static | function |
Returns the label of the cache context. Overrides CacheContextInterface:: |
|
UserCacheContextBase:: |
protected | property | The account object. | |
UserCacheContextBase:: |
public | function | Constructs a new UserCacheContextBase class. | 1 |