You are here

public function AddRoleToUser::processSettings in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Plugin/BusinessRulesAction/AddRoleToUser.php \Drupal\business_rules\Plugin\BusinessRulesAction\AddRoleToUser::processSettings()

Process the item settings before it's saved.

Parameters

array $settings: The settings to be processed before save the Business Rule Item.

\Drupal\business_rules\ItemInterface $item: The item being processed.

Return value

array The processed settings.

Overrides BusinessRulesItemPluginBase::processSettings

File

src/Plugin/BusinessRulesAction/AddRoleToUser.php, line 96

Class

AddRoleToUser
Class AddRoleToUser.

Namespace

Drupal\business_rules\Plugin\BusinessRulesAction

Code

public function processSettings(array $settings, ItemInterface $item) {
  $roles = $settings['roles'];
  foreach ($roles as $key => $role) {
    if ($key !== $role) {
      unset($roles[$key]);
    }
  }
  $settings['roles'] = $roles;
  switch ($settings['user_container']) {
    case 'current':
      unset($settings['variable']);
      unset($settings['uid']);
      break;
    case 'by_id':
      unset($settings['variable']);
      break;
    case 'variable':
      unset($settings['uid']);
      break;
  }
  return $settings;
}