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

Breadcrumb

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

function UserRolesCacheContext::getCacheableMetadata

Overrides CalculatedCacheContextInterface::getCacheableMetadata

File

core/lib/Drupal/Core/Cache/Context/UserRolesCacheContext.php, line 41

Class

UserRolesCacheContext
Defines the UserRolesCacheContext service, for "per role" caching.

Namespace

Drupal\Core\Cache\Context

Code

public function getCacheableMetadata($role = NULL) {
    return (new CacheableMetadata())->setCacheTags([
        'user:' . $this->user
            ->id(),
    ]);
}
RSS feed
Powered by Drupal