public function AllowedLanguagesManager::assignedLanguages in Allowed Languages 2.x
Get the allowed languages for the specified user.
Parameters
\Drupal\Core\Session\AccountInterface $account: The user to get allowed languages for.
Return value
array An array of allowed language ids.
Overrides AllowedLanguagesManagerInterface::assignedLanguages
1 call to AllowedLanguagesManager::assignedLanguages()
- AllowedLanguagesManager::hasPermissionForLanguage in src/
AllowedLanguagesManager.php - Checks if the user is allowed to translate the specified language.
File
- src/
AllowedLanguagesManager.php, line 66
Class
- AllowedLanguagesManager
- The allowed language manager controls access to content by language.
Namespace
Drupal\allowed_languagesCode
public function assignedLanguages(AccountInterface $account = NULL) {
$account = $this
->accountFromProxy($this->currentUser);
$language_values = [];
// Make sure the field exists before attempting to get languages.
if (!$account
->hasField('allowed_languages')) {
return $language_values;
}
// Get the id of each referenced language.
foreach ($account
->get('allowed_languages')
->getValue() as $item) {
$language_values[] = $item['target_id'];
}
return $language_values;
}