You are here

public function SocialProfileTagService::getChildrens in Open Social 10.2.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_profile/src/SocialProfileTagService.php \Drupal\social_profile\SocialProfileTagService::getChildrens()

Returns the children of top level term items.

Parameters

int $category: The category you want to fetch the child items from.

Return value

array An array of child items.

Overrides SocialProfileTagServiceInterface::getChildrens

File

modules/social_features/social_profile/src/SocialProfileTagService.php, line 118

Class

SocialProfileTagService
Provide a service for profile tagging.

Namespace

Drupal\social_profile

Code

public function getChildrens($category) {

  // Define as array.
  $options = [];

  // Get the site's current language.
  $current_lang = $this->languageManager
    ->getCurrentLanguage()
    ->getId();
  if (!empty($current_lang_terms = $this->taxonomyStorage
    ->loadTree('profile_tag', $category, 1, FALSE, $current_lang))) {
    $options = $this
      ->prepareTermOptions($current_lang_terms);
  }
  elseif (!empty($default_lang_terms = $this->taxonomyStorage
    ->loadTree('profile_tag', $category, 1, FALSE))) {
    $options = $this
      ->prepareTermOptions($default_lang_terms);
  }

  // Return array.
  return $options;
}