You are here

public function AdvbanIpManager::banText in Advanced ban 8

Create formatted ban text.

Parameters

array $variables: Variables array.

Return value

string Formatted ban text.

Overrides AdvbanIpManagerInterface::banText

File

src/AdvbanIpManager.php, line 318

Class

AdvbanIpManager
Ban IP manager.

Namespace

Drupal\advban

Code

public function banText(array $variables) {
  $ban_text = $this->config
    ->get('advban.settings')
    ->get('advban_ban_text') ?: '@ip has been banned';
  $ban_text_params = [
    '@ip' => $variables['ip'],
  ];
  $expiry_date = $variables['expiry_date'];
  if (!empty($expiry_date)) {
    $ban_text = $this->config
      ->get('advban.settings')
      ->get('advban_ban_expire_text') ?: '@ip has been banned up to @expiry_date';
    $ban_text_params['@expiry_date'] = $this->dateFormatter
      ->format($expiry_date);
  }
  return new FormattableMarkup($ban_text, $ban_text_params);
}