class UserCacheContextBase

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Cache/Context/UserCacheContextBase.php \Drupal\Core\Cache\Context\UserCacheContextBase
  2. 10 core/lib/Drupal/Core/Cache/Context/UserCacheContextBase.php \Drupal\Core\Cache\Context\UserCacheContextBase
  3. 11.x core/lib/Drupal/Core/Cache/Context/UserCacheContextBase.php \Drupal\Core\Cache\Context\UserCacheContextBase

Base class for user-based cache contexts.

Subclasses need to implement either \Drupal\Core\Cache\Context\CacheContextInterface or \Drupal\Core\Cache\Context\CalculatedCacheContextInterface.

Hierarchy

Expanded class hierarchy of UserCacheContextBase

1 file declares its use of UserCacheContextBase
NodeAccessGrantsCacheContext.php in core/modules/node/src/Cache/NodeAccessGrantsCacheContext.php

File

core/lib/Drupal/Core/Cache/Context/UserCacheContextBase.php, line 14

Namespace

Drupal\Core\Cache\Context
View source
abstract class UserCacheContextBase {
    
    /**
     * The account object.
     *
     * @var \Drupal\Core\Session\AccountInterface
     */
    protected $user;
    
    /**
     * Constructs a new UserCacheContextBase class.
     *
     * @param \Drupal\Core\Session\AccountInterface $user
     *   The current user.
     */
    public function __construct(AccountInterface $user) {
        $this->user = $user;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
UserCacheContextBase::$user protected property The account object.
UserCacheContextBase::__construct public function Constructs a new UserCacheContextBase class. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.