public function UserVariableHasRole::getSettingsForm in Business Rules 8
Same name and namespace in other branches
- 2.x src/Plugin/BusinessRulesCondition/UserVariableHasRole.php \Drupal\business_rules\Plugin\BusinessRulesCondition\UserVariableHasRole::getSettingsForm()
Return the form array.
@internal param array $form
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state object.
\Drupal\business_rules\ItemInterface $item: The configured item.
Return value
array The render array for the settings form.
Overrides BusinessRulesItemPluginBase::getSettingsForm
File
- src/
Plugin/ BusinessRulesCondition/ UserVariableHasRole.php, line 32
Class
- UserVariableHasRole
- Class UserVariableHasRole.
Namespace
Drupal\business_rules\Plugin\BusinessRulesConditionCode
public function getSettingsForm(array &$form, FormStateInterface $form_state, ItemInterface $item) {
$settings['user_variable'] = [
'#type' => 'select',
'#required' => TRUE,
'#title' => t('User variable'),
'#description' => t('Select the variable that represents the user.'),
'#options' => $this->util
->getVariablesOptions([
'user_variable',
'entity_empty_variable',
], [
'user',
], [
'user',
]),
'#default_value' => $item
->getSettings('user_variable'),
];
$settings['roles'] = [
'#type' => 'checkboxes',
'#title' => t('Roles'),
'#required' => TRUE,
'#options' => $this->util
->getUserRolesOptions(),
'#default_value' => is_array($item
->getSettings('roles')) ? $item
->getSettings('roles') : [],
];
$settings['criteria'] = [
'#type' => 'select',
'#title' => t('Match criteria'),
'#description' => t('The condition will check if current user has all selected roles or at least one role?'),
'#required' => TRUE,
'#default_value' => $item
->getSettings('criteria'),
'#options' => [
'all' => t('All roles'),
'one' => t('At least one role'),
],
];
return $settings;
}