class AutobanBatch in Automatic IP ban (Autoban) 8
Class AutobanBatch.
Provides the batch operations.
Hierarchy
- class \Drupal\autoban\AutobanBatch
Expanded class hierarchy of AutobanBatch
1 file declares its use of AutobanBatch
- autoban.module in ./
autoban.module - Autoban entity type configuration.
File
- src/
AutobanBatch.php, line 17 - Contains \Drupal\autoban\AutobanBatch.
Namespace
Drupal\autobanView source
class AutobanBatch {
/**
* IP ban.
*/
public static function ipBan($rule, &$context) {
$controller = \Drupal::service('autoban');
$banned_ip = $controller
->getBannedIp($rule);
$banned = $controller
->banIpList($banned_ip, $rule);
$context['message'] = t('rule %rule banned @banned', [
'%rule' => $rule,
'@banned' => $banned,
]);
// Calculate total banned IPs for all autoban rules.
$total_banned = $banned;
if (isset($context['results'])) {
$total_banned += intval($context['results']);
}
$context['results'] = $total_banned;
}
/**
* IP ban finished.
*/
public static function ipBanFinished($success, $results, $operations) {
if ($success) {
$message = t('IP bans was finished. Total banned: %results', [
'%results' => $results,
]);
\Drupal::messenger()
->addMessage($message);
\Drupal::service('logger.factory')
->get('autoban')
->notice($message);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AutobanBatch:: |
public static | function | IP ban. | |
AutobanBatch:: |
public static | function | IP ban finished. |