public function SocialProfileTagService::getChildrens in Open Social 10.3.x
Same name and namespace in other branches
- 10.2.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_profileCode
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;
}