public function DatabaseBackend::isAllowed

Implements Drupal\Core\Flood\FloodInterface::isAllowed().

Overrides FloodInterface::isAllowed

File

drupal/core/lib/Drupal/Core/Flood/DatabaseBackend.php, line 79
Definition of Drupal\Core\Flood\DatabaseBackend.

Class

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

Namespace

Drupal\Core\Flood

Code

public function isAllowed($name, $threshold, $window = 3600, $identifier = NULL) {
  if (!isset($identifier)) {
    $identifier = $this->request
      ->getClientIp();
  }
  $number = $this->connection
    ->select('flood', 'f')
    ->condition('event', $name)
    ->condition('identifier', $identifier)
    ->condition('timestamp', REQUEST_TIME - $window, '>')
    ->countQuery()
    ->execute()
    ->fetchField();
  return $number < $threshold;
}