You are here

public function UserSectionStorage::resetCache in Workbench Access 8

Reset the static cache from an external change.

2 calls to UserSectionStorage::resetCache()
UserSectionStorage::addUser in src/UserSectionStorage.php
Adds a set of sections to a user.
UserSectionStorage::removeUser in src/UserSectionStorage.php
Removes a set of sections to a user.

File

src/UserSectionStorage.php, line 209

Class

UserSectionStorage
Defines a class for storing and retrieving sections assigned to a user.

Namespace

Drupal\workbench_access

Code

public function resetCache(AccessSchemeInterface $scheme, $user_id = NULL) {
  if ($user_id && isset($this->userSectionCache[$scheme
    ->id()][$user_id])) {
    unset($this->userSectionCache[$scheme
      ->id()][$user_id]);
  }
  elseif (isset($this->userSectionCache[$scheme
    ->id()])) {
    unset($this->userSectionCache[$scheme
      ->id()]);
  }

  // Invalidate entity access tags that we use.
  // @TODO: we should inject the cache service.
  Cache::invalidateTags([
    'config:workbench_access.access_scheme.' . $scheme
      ->id(),
  ]);
}