function DatabaseBackend::clearByPrefix

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::clearByPrefix()

Makes the flood control mechanism forget an event by identifier prefix.

Parameters

string $name: The name of an event.

string $prefix: The prefix of the identifier to be cleared.

Overrides PrefixFloodInterface::clearByPrefix

File

core/lib/Drupal/Core/Flood/DatabaseBackend.php, line 120

Class

DatabaseBackend
Defines the database flood backend. This is the default Drupal backend.

Namespace

Drupal\Core\Flood

Code

public function clearByPrefix(string $name, string $prefix) : void {
  try {
    $this->connection
      ->delete(static::TABLE_NAME)
      ->condition('event', $name)
      ->condition('identifier', $prefix . '-%', 'LIKE')
      ->execute();
  } catch (\Exception $e) {
    $this->catchException($e);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.