function MemoryBackend::register

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

Overrides FloodInterface::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,
    ];
}

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