You are here

function hook_social_follow_taxonomy_terms_list_alter 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.api.php \hook_social_follow_taxonomy_terms_list_alter()
  2. 10.1.x modules/social_features/social_follow_taxonomy/social_follow_taxonomy.api.php \hook_social_follow_taxonomy_terms_list_alter()
  3. 10.2.x modules/social_features/social_follow_taxonomy/social_follow_taxonomy.api.php \hook_social_follow_taxonomy_terms_list_alter()

Provide a method to alter array of terms.

Parameters

array $term_ids: An array of term ids.

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

Return value

array Array of term ids.

1 function implements hook_social_follow_taxonomy_terms_list_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

social_follow_tag_social_follow_taxonomy_terms_list_alter in modules/social_features/social_follow_taxonomy/modules/social_follow_tag/social_follow_tag.module
Implements hook_social_follow_taxonomy_terms_list_alter().
1 invocation of hook_social_follow_taxonomy_terms_list_alter()
social_follow_taxonomy_terms_list in modules/social_features/social_follow_taxonomy/social_follow_taxonomy.module
Provide an array of terms related to entity.

File

modules/social_features/social_follow_taxonomy/social_follow_taxonomy.api.php, line 28
Hooks provided by the Social Follow Taxonomy Term module.

Code

function hook_social_follow_taxonomy_terms_list_alter(array &$term_ids, EntityInterface $entity) {

  /** @var \Drupal\node\Entity\Node $entity */
  if ($entity instanceof NodeInterface) {
    if ($entity
      ->hasField('field_terms') && !empty($entity
      ->get('field_terms')
      ->getValue())) {
      $terms = $entity
        ->get('field_terms')
        ->getValue();
      foreach ($terms as $term) {
        $term_ids[] = $term['target_id'];
      }
    }
  }
  return $term_ids;
}