You are here

public function MemoryBackend::register in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::register()
  2. 9 core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::register()

File

core/lib/Drupal/Core/Flood/MemoryBackend.php, line 37

Class

MemoryBackend
Defines the memory flood backend. This is used for testing.

Namespace

Drupal\Core\Flood

Code

public function register($name, $window = 3600, $identifier = NULL) {
  if (!isset($identifier)) {
    $identifier = $this->requestStack
      ->getCurrentRequest()
      ->getClientIp();
  }

  // We can't use REQUEST_TIME here, because that would not guarantee
  // uniqueness.
  $time = microtime(TRUE);
  $this->events[$name][$identifier][] = [
    'expire' => $time + $window,
    'time' => $time,
  ];
}