public function AccessStorage::getUserFormValue in Permissions by Term 8
Same name and namespace in other branches
- 8.2 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 525
Class
- AccessStorage
- Class AccessStorage.
Namespace
Drupal\permissions_by_term\ServiceCode
public function getUserFormValue($aAllowedUsers) {
$sUserInfos = '';
if (!empty($aAllowedUsers)) {
foreach ($aAllowedUsers as $oUser) {
$iUid = intval($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;
}