You are here

UserCacheContext.php in Zircon Profile 8

Same filename and directory in other branches
  1. 8.0 core/lib/Drupal/Core/Cache/Context/UserCacheContext.php

File

core/lib/Drupal/Core/Cache/Context/UserCacheContext.php
View source
<?php

/**
 * @file
 * Contains \Drupal\Core\Cache\Context\UserCacheContext.
 */
namespace Drupal\Core\Cache\Context;

use Drupal\Core\Cache\CacheableMetadata;

/**
 * Defines the UserCacheContext service, for "per user" caching.
 *
 * Cache context ID: 'user'.
 */
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();
  }

}

Classes

Namesort descending Description
UserCacheContext Defines the UserCacheContext service, for "per user" caching.