public function FloodUnblockManager::floodUnblockClearEvent in Flood control 2.0.x
Removes rows from flood table.
Parameters
string $fid: The flood table entry ID.
Overrides FloodUnblockManagerInterface::floodUnblockClearEvent
File
- src/
FloodUnblockManager.php, line 118
Class
- FloodUnblockManager
- Provides Flood Unblock actions.
Namespace
Drupal\flood_controlCode
public function floodUnblockClearEvent($fid) {
$txn = $this->database
->startTransaction('flood_unblock_clear');
try {
$query = $this->database
->delete('flood')
->condition('fid', $fid);
$success = $query
->execute();
if ($success) {
$this->messenger
->addMessage($this
->t('Flood entries cleared.'), 'status', FALSE);
}
} catch (\Exception $e) {
// Something went wrong somewhere, so roll back now.
$txn
->rollback();
// Log the exception to watchdog.
watchdog_exception('type', $e);
$this->messenger
->addMessage($this
->t('Error: @error', [
'@error' => (string) $e,
]), 'error');
}
}