You are here

public function AutobanController::ruleTypeList in Automatic IP ban (Autoban) 8

Get rule type names list.

Parameters

int $index: Rule type index (optional).

Return value

string|array User rule name or rule type names list.

File

src/Controller/AutobanController.php, line 504

Class

AutobanController
Provides an Autoban functional.

Namespace

Drupal\autoban\Controller

Code

public function ruleTypeList($index = NULL) {
  $rule_types = [
    AutobanUtils::AUTOBAN_RULE_ANY => $this
      ->t('Any'),
    AutobanUtils::AUTOBAN_RULE_MANUAL => $this
      ->t('Manual'),
    AutobanUtils::AUTOBAN_RULE_AUTO => $this
      ->t('Automatic'),
  ];
  if ($index === NULL) {
    return $rule_types;
  }
  else {
    if (!isset($rule_types[$index])) {
      $index = AutobanUtils::AUTOBAN_RULE_ANY;
    }
    return $rule_types[$index];
  }
}