You are here

public function ProfileStatisticBlock::getCacheTags in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_profile/src/Plugin/Block/ProfileStatisticBlock.php \Drupal\social_profile\Plugin\Block\ProfileStatisticBlock::getCacheTags()
  2. 10.3.x modules/social_features/social_profile/src/Plugin/Block/ProfileStatisticBlock.php \Drupal\social_profile\Plugin\Block\ProfileStatisticBlock::getCacheTags()
  3. 10.0.x modules/social_features/social_profile/src/Plugin/Block/ProfileStatisticBlock.php \Drupal\social_profile\Plugin\Block\ProfileStatisticBlock::getCacheTags()
  4. 10.1.x modules/social_features/social_profile/src/Plugin/Block/ProfileStatisticBlock.php \Drupal\social_profile\Plugin\Block\ProfileStatisticBlock::getCacheTags()
  5. 10.2.x modules/social_features/social_profile/src/Plugin/Block/ProfileStatisticBlock.php \Drupal\social_profile\Plugin\Block\ProfileStatisticBlock::getCacheTags()

The cache tags associated with this object.

When this object is modified, these cache tags will be invalidated.

Return value

string[] A set of cache tags.

Overrides ContextAwarePluginBase::getCacheTags

File

modules/social_features/social_profile/src/Plugin/Block/ProfileStatisticBlock.php, line 84

Class

ProfileStatisticBlock
Provides a 'ProfileStatisticBlock' block.

Namespace

Drupal\social_profile\Plugin\Block

Code

public function getCacheTags() {
  $account = $this
    ->getContextValue('user');
  $storage = $this->entityTypeManager
    ->getStorage('profile');
  $profile = $storage
    ->loadByUser($account, 'profile');
  $tags = [
    'user:' . $account
      ->id(),
  ];
  if ($profile) {
    $tags[] = 'profile:' . $profile
      ->id();
  }
  return Cache::mergeTags(parent::getCacheTags(), $tags);
}