You are here

public function RemoveUserRole::processSettings in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Plugin/BusinessRulesAction/RemoveUserRole.php \Drupal\business_rules\Plugin\BusinessRulesAction\RemoveUserRole::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/RemoveUserRole.php, line 96

Class

RemoveUserRole
Class RemoveUserRole.

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;
}