UserCacheContextBase.php

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

Namespace

Drupal\Core\Cache\Context

File

core/lib/Drupal/Core/Cache/Context/UserCacheContextBase.php

View source
<?php

namespace Drupal\Core\Cache\Context;

use Drupal\Core\Session\AccountInterface;

/**
 * Base class for user-based cache contexts.
 *
 * Subclasses need to implement either
 * \Drupal\Core\Cache\Context\CacheContextInterface or
 * \Drupal\Core\Cache\Context\CalculatedCacheContextInterface.
 */
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;
    }

}

Classes

Title Deprecated Summary
UserCacheContextBase Base class for user-based cache contexts.

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