Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UserFloodEvent.php

function 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 66

Class

UserFloodEvent
Provides a user flood event for event listeners.

Namespace

Drupal\user\Event

Code

public function __construct($name, $threshold, $window, $identifier) {
    $this->name = $name;
    $this->threshold = $threshold;
    $this->window = $window;
    $this->identifier = $identifier;
    // The identifier could be a uid or an IP, or a composite of both.
    if (is_numeric($identifier)) {
        $this->uid = $identifier;
        return;
    }
    if (str_contains($identifier, '-')) {
        [
            $uid,
            $ip,
        ] = explode('-', $identifier);
        $this->uid = $uid;
        $this->ip = $ip;
        return;
    }
    $this->ip = $identifier;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal