You are here

function social_follow_taxonomy_term_followers_count in Open Social 10.3.x

Same name and namespace in other branches
  1. 10.0.x modules/social_features/social_follow_taxonomy/social_follow_taxonomy.module \social_follow_taxonomy_term_followers_count()
  2. 10.1.x modules/social_features/social_follow_taxonomy/social_follow_taxonomy.module \social_follow_taxonomy_term_followers_count()
  3. 10.2.x modules/social_features/social_follow_taxonomy/social_follow_taxonomy.module \social_follow_taxonomy_term_followers_count()

Function for counting the number of followers of the term.

Parameters

\Drupal\taxonomy\TermInterface $term: Term entity.

Return value

int Count of followers.

3 calls to social_follow_taxonomy_term_followers_count()
SocialFollowTagLazyBuilder::lazyBuild in modules/social_features/social_follow_taxonomy/modules/social_follow_tag/src/SocialFollowTagLazyBuilder.php
Returns tags for lazy builder.
SocialFollowTagLazyBuilder::popupLazyBuild in modules/social_features/social_follow_taxonomy/modules/social_follow_tag/src/SocialFollowTagLazyBuilder.php
Returns render array for tag follow popup.
social_follow_landing_page_preprocess_paragraph in modules/social_features/social_follow_taxonomy/modules/social_follow_landing_page/social_follow_landing_page.module
Implements hook_preprocess_HOOK().

File

modules/social_features/social_follow_taxonomy/social_follow_taxonomy.module, line 388
Contains social_follow_taxonomy.module.

Code

function social_follow_taxonomy_term_followers_count(TermInterface $term) {
  $count = 0;

  /** @var \Drupal\flag\FlagCountManagerInterface $flag_count_manager */
  $flag_count_manager = \Drupal::service('flag.count');
  $term_followers_count = $flag_count_manager
    ->getEntityFlagCounts($term);
  if (isset($term_followers_count['follow_term'])) {
    $count = $term_followers_count['follow_term'];
  }
  return $count;
}