You are here

function social_tagging_preprocess_profile in Open Social 10.1.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_tagging/social_tagging.module \social_tagging_preprocess_profile()
  2. 10.0.x modules/social_features/social_tagging/social_tagging.module \social_tagging_preprocess_profile()
  3. 10.2.x modules/social_features/social_tagging/social_tagging.module \social_tagging_preprocess_profile()

Implements hook_preprocess_profile().

File

modules/social_features/social_tagging/social_tagging.module, line 542
Contains social_tagging.module.

Code

function social_tagging_preprocess_profile(array &$variables) {

  /** @var \Drupal\social_tagging\SocialTaggingService $tag_service */
  $tag_service = \Drupal::service('social_tagging.tag_service');
  $variables['social_tagging_profile_active'] = FALSE;
  if ($tag_service
    ->active() && $tag_service
    ->profileActive()) {
    $variables['social_tagging_profile_active'] = TRUE;

    /** @var \Drupal\profile\Entity\ProfileInterface $profile */
    $profile = $variables['profile'];
    if (!$profile
      ->get('social_tagging')
      ->isEmpty()) {
      $tags = $profile
        ->get('social_tagging')
        ->getValue();
      $variables['social_tagging_allow_split'] = $tag_service
        ->allowSplit();
      $variables['social_tagging_hierarchy'] = $tag_service
        ->buildHierarchy($tags, 'profile');
    }
  }
}