public function AccessStorage::getUserFormValue in Permissions by Term 8.2
Same name and namespace in other branches
- 8 src/Service/AccessStorage.php \Drupal\permissions_by_term\Service\AccessStorage::getUserFormValue()
The form value for allowed users as string to be shown to the user.
Parameters
User[] $aAllowedUsers: An array with the allowed users.
Return value
null|string Either null or the user name.
File
- src/
Service/ AccessStorage.php, line 527
Class
- AccessStorage
- Class AccessStorage.
Namespace
Drupal\permissions_by_term\ServiceCode
public function getUserFormValue($aAllowedUsers) {
$sUserInfos = '';
if (!empty($aAllowedUsers)) {
foreach ($aAllowedUsers as $oUser) {
$iUid = (int) $oUser
->id();
if ($iUid !== 0) {
$sUsername = $oUser
->getDisplayName();
}
else {
$sUsername = t('Anonymous User');
}
$sUserInfos .= "{$sUsername} ({$iUid}), ";
}
// Remove space and comma at the end of the string.
$sUserInfos = substr($sUserInfos, 0, -2);
}
return $sUserInfos;
}