You are here

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

Get user type names list.

Parameters

int $index: User type index (optional).

Return value

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

File

src/Controller/AutobanController.php, line 477

Class

AutobanController
Provides an Autoban functional.

Namespace

Drupal\autoban\Controller

Code

public function userTypeList($index = NULL) {
  $user_types = [
    AutobanUtils::AUTOBAN_USER_ANY => $this
      ->t('Any'),
    AutobanUtils::AUTOBAN_USER_ANONYMOUS => $this
      ->t('Anonymous'),
    AutobanUtils::AUTOBAN_USER_AUTHENTICATED => $this
      ->t('Authenticated'),
  ];
  if ($index === NULL) {
    return $user_types;
  }
  else {
    if (!isset($user_types[$index])) {
      $index = AutobanUtils::AUTOBAN_USER_ANY;
    }
    return $user_types[$index];
  }
}