function UserFloodEvent::__construct
Same name and namespace in other branches
- 11.x core/modules/user/src/Event/UserFloodEvent.php \Drupal\user\Event\UserFloodEvent::__construct()
- 10 core/modules/user/src/Event/UserFloodEvent.php \Drupal\user\Event\UserFloodEvent::__construct()
- 9 core/modules/user/src/Event/UserFloodEvent.php \Drupal\user\Event\UserFloodEvent::__construct()
Constructs a user flood event object.
Parameters
string $name: The name of the flood event.
int $threshold: The threshold for the flood event.
int $window: The window for the flood event.
string $identifier: The identifier of the flood event.
File
-
core/
modules/ user/ src/ Event/ UserFloodEvent.php, line 38
Class
- UserFloodEvent
- Provides a user flood event for event listeners.
Namespace
Drupal\user\EventCode
public function __construct(protected $name, protected $threshold, protected $window, protected $identifier) {
// The identifier could be a uid or an IP, or a composite of both.
if (is_numeric($this->identifier)) {
$this->uid = $this->identifier;
return;
}
if (str_contains($this->identifier, '-')) {
[$uid, $ip] = explode('-', $this->identifier);
$this->uid = $uid;
$this->ip = $ip;
return;
}
$this->ip = $this->identifier;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.