You are here

function _webform_clear_webform_submission_list_cache_tag in Webform 6.x

Same name and namespace in other branches
  1. 8.5 webform.module \_webform_clear_webform_submission_list_cache_tag()

Invalidate 'webform_submission_list' cache tag when user or role is updated.

Once the below issue is resolved we should rework this approach.

Issue #2811041: Allow views base tables to define additional cache tags and max age. https://www.drupal.org/project/drupal/issues/2811041

Parameters

\Drupal\Core\Entity\EntityInterface $entity: An entity.

See also

\Drupal\webform\Entity\WebformSubmission

webform_query_webform_submission_access_alter()

2 calls to _webform_clear_webform_submission_list_cache_tag()
webform_entity_delete in ./webform.module
Implements hook_entity_delete().
webform_entity_update in ./webform.module
Implements hook_entity_update().

File

./webform.module, line 373
Enables the creation of webforms and questionnaires.

Code

function _webform_clear_webform_submission_list_cache_tag(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() === 'user') {
    $original_target_ids = [];
    if ($entity->original) {
      foreach ($entity->original->roles as $item) {
        $original_target_ids[$item->target_id] = $item->target_id;
      }
    }
    $target_ids = [];
    foreach ($entity->roles as $item) {
      $target_ids[$item->target_id] = $item->target_id;
    }
    if (array_diff_assoc($original_target_ids, $target_ids)) {
      Cache::invalidateTags([
        'webform_submission_list',
      ]);
    }
  }
  elseif ($entity
    ->getEntityTypeId() === 'user_role') {
    Cache::invalidateTags([
      'webform_submission_list',
    ]);
  }
}