Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UserCacheContext.php

class UserCacheContext

Defines the UserCacheContext service, for "per user" caching.

Cache context ID: 'user'.

Hierarchy

  • class \Drupal\Core\Cache\Context\UserCacheContextBase
    • class \Drupal\Core\Cache\Context\UserCacheContext extends \Drupal\Core\Cache\Context\UserCacheContextBase implements \Drupal\Core\Cache\Context\CacheContextInterface

Expanded class hierarchy of UserCacheContext

File

core/lib/Drupal/Core/Cache/Context/UserCacheContext.php, line 12

Namespace

Drupal\Core\Cache\Context
View source
class UserCacheContext extends UserCacheContextBase implements CacheContextInterface {
    
    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('User');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getContext() {
        return $this->user
            ->id();
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheableMetadata() {
        return new CacheableMetadata();
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
UserCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
UserCacheContext::getContext public function Returns the string representation of the cache context. Overrides CacheContextInterface::getContext
UserCacheContext::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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal