protected function ChannelForm::getAuthorizedUsersOptions in Entity Share 8
Same name and namespace in other branches
- 8.3 modules/entity_share_server/src/Form/ChannelForm.php \Drupal\entity_share_server\Form\ChannelForm::getAuthorizedUsersOptions()
- 8.2 modules/entity_share_server/src/Form/ChannelForm.php \Drupal\entity_share_server\Form\ChannelForm::getAuthorizedUsersOptions()
Helper function.
Get users with permission entity_share_server_access_channels.
Return value
array An array of options.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
1 call to ChannelForm::getAuthorizedUsersOptions()
- ChannelForm::form in modules/
entity_share_server/ src/ Form/ ChannelForm.php - Gets the actual form array to be built.
File
- modules/
entity_share_server/ src/ Form/ ChannelForm.php, line 671
Class
- ChannelForm
- Class ChannelForm.
Namespace
Drupal\entity_share_server\FormCode
protected function getAuthorizedUsersOptions() {
$authorized_users = [];
$authorized_roles = [];
$users = [];
// Filter on roles having access to the channel list.
/** @var \Drupal\user\RoleInterface[] $roles */
$roles = $this->entityTypeManager
->getStorage('user_role')
->loadMultiple();
foreach ($roles as $role) {
if ($role
->hasPermission('entity_share_server_access_channels')) {
$authorized_roles[] = $role
->id();
}
}
if (!empty($authorized_roles)) {
$users = $this->entityTypeManager
->getStorage('user')
->loadByProperties([
'roles' => $authorized_roles,
]);
}
foreach ($users as $user) {
$authorized_users[$user
->uuid()] = $user
->label();
}
return $authorized_users;
}