I have a custom Views access plugin that check access against a value in the current User's Profile (entity) field value.
The plugin works but if I change the profile field value the access does not check again until the cache is cleared. I know this is an issue with setting up the cache tags/contexts but I cannot not figure out what is needed so that the cache is cleared when the user profile is updated.
Right now I'm not using any cache tags/contexts in my View access plug and I've tried various combinations without luck. Help!
Current cache functions:
public function getCacheMaxAge() {
return Cache::PERMANENT;
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return ['user'];
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
$profile = \Drupal::entityManager()->getStorage('profile')->loadByUser(user_load(\Drupal::currentUser()->id()), 'employee');
return $profile->getCacheTags();
}