public function Role::buildConfigurationForm in Workbench Email 2.x
Same name and namespace in other branches
- 8 src/Plugin/RecipientType/Role.php \Drupal\workbench_email\Plugin\RecipientType\Role::buildConfigurationForm()
Generates a recipient types's settings form.
Parameters
array $form: A minimally prepopulated form array.
\Drupal\Core\Form\FormStateInterface $form_state: The state of the (entire) configuration form.
Return value
array The $form array with additional form elements for the settings of this recipient type. The submitted form values should match $this->settings.
Overrides RecipientTypeBase::buildConfigurationForm
1 call to Role::buildConfigurationForm()
- RolesWithAccess::buildConfigurationForm in src/
Plugin/ RecipientType/ RolesWithAccess.php - Generates a recipient types's settings form.
1 method overrides Role::buildConfigurationForm()
- RolesWithAccess::buildConfigurationForm in src/
Plugin/ RecipientType/ RolesWithAccess.php - Generates a recipient types's settings form.
File
- src/
Plugin/ RecipientType/ Role.php, line 68
Class
- Role
- Provides a recipient type of user role.
Namespace
Drupal\workbench_email\Plugin\RecipientTypeCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$roles = array_filter($this->entityTypeManager
->getStorage('user_role')
->loadMultiple(), function (RoleInterface $role) {
return !in_array($role
->id(), [
RoleInterface::ANONYMOUS_ID,
RoleInterface::AUTHENTICATED_ID,
], TRUE);
});
$role_options = array_map(function (RoleInterface $role) {
return $role
->label();
}, $roles);
return [
'roles' => [
'#type' => 'checkboxes',
'#title' => $this
->t('Roles'),
'#description' => $this
->t('Send to all users with selected roles'),
'#options' => $role_options,
'#default_value' => $this
->getRoles(),
],
];
}